2023-07-26 00:42:12 -06:00
|
|
|
package graphvent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNodeDB(t *testing.T) {
|
|
|
|
ctx := logTestContext(t, []string{"test", "db", "node", "policy"})
|
|
|
|
node_type := NodeType("test")
|
2023-07-26 11:56:10 -06:00
|
|
|
err := ctx.RegisterNodeType(node_type, []ExtType{"ACL"})
|
2023-07-26 00:42:12 -06:00
|
|
|
fatalErr(t, err)
|
2023-07-26 15:08:14 -06:00
|
|
|
node := NewNode(ctx, RandID(), node_type)
|
2023-07-26 00:42:12 -06:00
|
|
|
node.Extensions[ACLExtType] = &ACLExt{
|
|
|
|
Delegations: NodeMap{},
|
|
|
|
}
|
|
|
|
|
|
|
|
context := NewWriteContext(ctx)
|
2023-07-26 15:08:14 -06:00
|
|
|
err = UpdateStates(context, node, NewACLInfo(node, []string{"test"}), func(context *StateContext) error {
|
2023-07-26 00:42:12 -06:00
|
|
|
ser, err := node.Serialize()
|
2023-07-26 11:56:10 -06:00
|
|
|
ctx.Log.Logf("test", "NODE_SER: %+v", ser)
|
2023-07-26 00:42:12 -06:00
|
|
|
return err
|
|
|
|
})
|
|
|
|
fatalErr(t, err)
|
|
|
|
|
2023-07-26 15:08:14 -06:00
|
|
|
ctx.Nodes = NodeMap{}
|
2023-07-26 00:42:12 -06:00
|
|
|
_, err = LoadNode(ctx, node.ID)
|
|
|
|
fatalErr(t, err)
|
|
|
|
}
|