-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate_test.go
More file actions
36 lines (30 loc) · 780 Bytes
/
template_test.go
File metadata and controls
36 lines (30 loc) · 780 Bytes
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
34
35
36
package main
import (
"bytes"
"encoding/xml"
"testing"
"github.com/stretchr/testify/assert"
)
// Make sure the index page template can render, provided it as a model of data.
// This is only testing the template renders not its contents.
func TestTemplateRendering(t *testing.T) {
model := Model{
Containers: []Container{
{
Ports: []*Port{
{9999, 8888, "TestPort", "/"},
{9999, 8888, "", "/"},
},
Name: "TestContainer",
Image: "test/dockerimage",
},
},
}
rendered := &bytes.Buffer{}
err := getIndexTpl().Execute(rendered, model)
assert.NoError(t, err)
// HTML is XML, make sure it can be parsed
// TODO: check if there is a stdlib xhml parser
err = xml.Unmarshal(rendered.Bytes(), new(interface{}))
assert.NoError(t, err)
}