File: template_test.go

package info (click to toggle)
golang-1.7 1.7.4-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch, stretch-backports
  • size: 67,920 kB
  • sloc: asm: 43,658; ansic: 7,818; sh: 1,492; perl: 1,131; xml: 623; python: 286; yacc: 155; makefile: 109; cpp: 22; f90: 8; awk: 7
file content (29 lines) | stat: -rw-r--r-- 552 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package template

import (
	"bytes"
	"testing"
)

func TestTemplateClone(t *testing.T) {
	// https://golang.org/issue/12996
	orig := New("name")
	clone, err := orig.Clone()
	if err != nil {
		t.Fatal(err)
	}
	if len(clone.Templates()) != len(orig.Templates()) {
		t.Fatalf("Invalid length of t.Clone().Templates()")
	}

	const want = "stuff"
	parsed := Must(clone.Parse(want))
	var buf bytes.Buffer
	err = parsed.Execute(&buf, nil)
	if err != nil {
		t.Fatal(err)
	}
	if got := buf.String(); got != want {
		t.Fatalf("got %q; want %q", got, want)
	}
}