-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_contents_test.go
77 lines (68 loc) · 1.78 KB
/
server_contents_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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package varroa
import (
"fmt"
"io/ioutil"
"testing"
"time"
"github.com/stretchr/testify/assert"
"gitlab.com/catastrophic/assistance/logthis"
)
func TestHTMLIndex(t *testing.T) {
fmt.Println("\n --- Testing HTML Index. ---")
check := assert.New(t)
// setup logger
logthis.SetLevel(2)
// setting up
expectedFile := "test/test_index.html"
data := HTMLIndex{
Title: "VARROA MUSICA",
Time: time.Unix(1492953739, 0).UTC().Format("2006-01-02 15:04:05"),
Stats: []HTMLStats{
{
Name: "BLUE",
TrackerStats: [][]string{
{"Up: something", "Down: something else"},
{"Up: something", "Down: something else"},
},
GraphLinks: []HTMLLink{
{Name: "up", URL: "#blue_up"},
{Name: "down", URL: "#blue_down"},
},
Graphs: []HTMLLink{
{Title: "Red UP", Name: "blue_up", URL: "up.svg"},
{Title: "Red DOWN", Name: "blue_down", URL: "down.svg"},
},
},
{
Name: "PURPLE",
TrackerStats: [][]string{
{"Up: something!", "Down: something else!"},
{"Up: something!", "Down: something else!"},
},
GraphLinks: []HTMLLink{
{Name: "up", URL: "#purple_up"},
{Name: "down", URL: "#purple_down"},
},
Graphs: []HTMLLink{
{Title: "Purple UP", Name: "purple_up", URL: "nwup.svg"},
{Title: "Purple DOWN", Name: "purple_down", URL: "nwdown.svg"},
},
},
},
CSS: knownThemes[darkOrange].CSS(),
Script: indexJS,
}
// generating index
dataBytes, err := data.IndexStats()
check.Nil(err)
check.NotZero(dataBytes)
check.Nil(data.SetMainContentStats())
d, err := data.MainPage()
check.Nil(err)
// comparing with expected
expected, err := ioutil.ReadFile(expectedFile)
check.Nil(err)
check.Equal(len(expected), len(d))
check.Equal(expected, d)
// ioutil.WriteFile("test/generated.html", d, 0666)
}