iop/apps/node/internal/transport/session_test.go
toki de1dcc586a feat: edge node unit tests 및 관련 코드 변경
- node.go: node 핵심 로직 수정
- node_test.go: unit 테스트 업데이트
- parser_test.go: 파서 테스트 업데이트
- session_test.go: 세션 테스트 업데이트
- agent-task 로그 파일 추가
2026-05-02 20:53:49 +09:00

58 lines
1.1 KiB
Go

package transport_test
import (
"fmt"
"sync"
"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")
}
func TestSession_ConcurrentRegisterCancel(t *testing.T) {
sess := &transport.Session{}
var wg sync.WaitGroup
for i := 0; i < 100; i++ {
id := fmt.Sprintf("run-%d", i)
wg.Add(1)
go func(runID string) {
defer wg.Done()
sess.RegisterCancel(runID, func() {})
sess.CancelRun(runID)
sess.DeregisterCancel(runID)
}(id)
}
wg.Wait()
}