graphvent/lockable_test.go

44 lines
1.2 KiB
Go

2023-07-27 16:21:27 -06:00
package graphvent
import (
"testing"
"time"
2023-07-27 16:21:27 -06:00
)
const TestLockableType = NodeType("TEST_LOCKABLE")
func lockableTestContext(t *testing.T) *Context {
ctx := logTestContext(t, []string{"lockable", "test"})
err := ctx.RegisterNodeType(TestLockableType, []ExtType{ACLExtType, LockableExtType, ListenerExtType})
2023-07-27 16:21:27 -06:00
fatalErr(t, err)
return ctx
}
var link_policy = NewAllNodesPolicy([]SignalType{LinkSignalType})
func TestLinkStatus(t *testing.T) {
ctx := lockableTestContext(t)
l1_listener := NewListenerExt(10)
l1 := NewNode(ctx, RandID(), TestLockableType, nil,
l1_listener,
NewACLExt(&link_policy),
NewLockableExt(nil, nil, nil, nil),
)
l2_listener := NewListenerExt(10)
l2 := NewNode(ctx, RandID(), TestLockableType, nil,
l2_listener,
NewACLExt(&link_policy),
NewLockableExt(nil, nil, nil, nil),
)
// Link l2 as a requirement of l1
err := LinkRequirement(ctx, l1, l2.ID)
fatalErr(t, err)
2023-07-27 16:21:27 -06:00
(*GraphTester)(t).WaitForLinkState(ctx, l1_listener, "dep_link", time.Millisecond*100, "No dep_link")
(*GraphTester)(t).WaitForLinkState(ctx, l2_listener, "req_linked", time.Millisecond*100, "No req_linked")
}