-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpathvalue_test.go
32 lines (28 loc) · 972 Bytes
/
pathvalue_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
package whatnot
import (
"testing"
"time"
"github.com/databeast/whatnot/access"
"github.com/stretchr/testify/assert"
)
func TestPathElementValues(t *testing.T) {
t.Run("Set and Retrieve a value", setAndRetrieveValueOnElement)
}
func setAndRetrieveValueOnElement(t *testing.T) {
t.Log("Creating a Path Element, setting a Value on it and then retrieving that value")
gns := createTestNamespace(t)
err := gns.RegisterAbsolutePath(PathString("/testelem").ToAbsolutePath())
if !assert.Nil(t, err, "registering path returned error") {
t.Error(err.Error())
return
}
elem := gns.FetchAbsolutePath("/testelem")
if !assert.NotNil(t, elem, "registered path element is nil") {
t.Error("couldnt fetch test path element")
return
}
time.Sleep(time.Second)
elem.SetValue(ElementValue{Val: "test value"}, ChangeAdded, access.Role{})
val := elem.GetValue()
assert.Equal(t, ElementValue{Val: "test value"}, val, "retrieved value did not match original value")
}