- Add edge node unit tests and transport package - Add node test client and related artifacts - Update bootstrap, node, and config modules - Add proto generated files - Update Makefile and configuration files
38 lines
758 B
Go
38 lines
758 B
Go
package transport_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"iop/apps/node/internal/transport"
|
|
)
|
|
|
|
func TestSession_RegisterCancel_CancelRun(t *testing.T) {
|
|
sess := &transport.Session{}
|
|
called := false
|
|
|
|
sess.RegisterCancel("run-1", func() { called = true })
|
|
sess.CancelRun("run-1")
|
|
|
|
if !called {
|
|
t.Fatal("cancel function was not called")
|
|
}
|
|
}
|
|
|
|
func TestSession_DeregisterCancel(t *testing.T) {
|
|
sess := &transport.Session{}
|
|
called := false
|
|
|
|
sess.RegisterCancel("run-1", func() { called = true })
|
|
sess.DeregisterCancel("run-1")
|
|
sess.CancelRun("run-1")
|
|
|
|
if called {
|
|
t.Fatal("cancel function should not have been called after deregister")
|
|
}
|
|
}
|
|
|
|
func TestSession_CancelRun_UnknownID(t *testing.T) {
|
|
sess := &transport.Session{}
|
|
|
|
sess.CancelRun("missing-run")
|
|
}
|