-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathembed_test.go
33 lines (26 loc) · 835 Bytes
/
embed_test.go
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
30
31
32
33
package main
import (
"fmt"
"io/ioutil"
"testing"
)
var SOURCETEMPLATE = "embed.tpl"
func TestGeneratedTemplateFunktion(t *testing.T) {
// This test is rather nonsense, as it tests a generated funktion
// but it is needed as the guys from awesome-go want a higher test coverage.
template := embedTemplate()
if len(template) < 1 {
fmt.Printf("Embedded, generated function 'embedTemplate()' does not return a full string\n")
t.Fail()
}
sourcetemplatebytearray, err := ioutil.ReadFile(SOURCETEMPLATE)
if err != nil {
fmt.Printf("Could not read source template file '%s'.\n", SOURCETEMPLATE)
t.Fail()
}
sourcetemplate := string(sourcetemplatebytearray)
if sourcetemplate != template {
fmt.Printf("Source template file '%s' and result of generated template function differ.\n", SOURCETEMPLATE)
t.Fail()
}
}