-
Notifications
You must be signed in to change notification settings - Fork 1
/
node_test.go
46 lines (42 loc) · 1.22 KB
/
node_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
package hranoprovod
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestDBnodeMap(t *testing.T) {
t.Run("Given nodeMap", func(t *testing.T) {
nl := NewDBNodeMap()
t.Run("Creates new DBnodeMap", func(t *testing.T) {
assert.NotNil(t, nl)
})
t.Run("Adding new node", func(t *testing.T) {
node := NewDBNodeFromNode(NewParserNode("test"))
nl.Push(node)
t.Run("Increases the number of nodes in the list", func(t *testing.T) {
assert.Equal(t, 1, len(nl))
})
})
})
}
func TestNewLogNode(t *testing.T) {
t.Run("Given NewLogNode", func(t *testing.T) {
now := time.Now()
elements := NewElements()
elements.Add("test", 1.22)
logNode := NewLogNode(now, elements, nil)
t.Run("Creates new log node with the proper fields", func(t *testing.T) {
assert.True(t, logNode.Time.Equal(now))
assert.Equal(t, "test", (logNode.Elements)[0].Name)
assert.Equal(t, 1.22, (logNode.Elements)[0].Value)
})
})
t.Run("Given Parser Node", func(t *testing.T) {
t.Run("Creates new node on valid date", func(t *testing.T) {
node := NewParserNode("2006/01/02")
logNode, err := NewLogNodeFromElements(time.Now(), node.Elements, nil)
assert.NotNil(t, logNode)
assert.Nil(t, err)
})
})
}