Started lockable_test.go

gql_cataclysm
noah metz 2023-07-27 16:21:27 -06:00
parent 9d31394707
commit 7ebb519cd0
3 changed files with 36 additions and 0 deletions

@ -86,6 +86,12 @@ func LoadLockableExt(ctx *Context, data []byte) (Extension, error) {
return &ext, nil return &ext, nil
} }
func (ext *LockableExt) HandleLinkSignal(ctx *Context, source NodeID, node *Node, signal LinkSignal) {
ctx.Log.Logf("lockable", "LINK_SIGNAL: %+v", signal)
}
func (ext *LockableExt) Process(ctx *Context, source NodeID, node *Node, signal Signal) { func (ext *LockableExt) Process(ctx *Context, source NodeID, node *Node, signal Signal) {
ctx.Log.Logf("signal", "LOCKABLE_PROCESS: %s", node.ID) ctx.Log.Logf("signal", "LOCKABLE_PROCESS: %s", node.ID)
@ -121,6 +127,11 @@ func (ext *LockableExt) Process(ctx *Context, source NodeID, node *Node, signal
} }
} }
case Direct: case Direct:
switch sig := signal.(type) {
case LinkSignal:
ext.HandleLinkSignal(ctx, source, node, sig)
default:
}
default: default:
} }
} }

@ -0,0 +1,13 @@
package graphvent
import (
"testing"
)
func TestLockableLink(t *testing.T) {
ctx := logTestContext(t, []string{"lockable", "signal"})
LockableType := NodeType("TEST_LOCKABLE")
err := ctx.RegisterNodeType(LockableType, []ExtType{LockableExtType})
fatalErr(t, err)
}

@ -98,6 +98,18 @@ func NewStatusSignal(status string, source NodeID) StatusSignal {
} }
} }
type LinkSignal struct {
IDSignal
State string `json:"state"`
}
func NewLinkSignal(state string, source NodeID) LinkSignal {
return LinkSignal{
IDSignal: NewIDSignal("link", Direct, source),
State: state,
}
}
type StartChildSignal struct { type StartChildSignal struct {
IDSignal IDSignal
Action string `json:"action"` Action string `json:"action"`