Files
go-sip/internal/rpc/execution_journal_mode_test.go

26 lines
893 B
Go

package rpc
import (
"path/filepath"
"testing"
agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1"
)
func TestExecutionJournalCannotCrossAdapterModes(t *testing.T) {
for _, mode := range []string{"mixed", "real"} {
t.Run(mode, func(t *testing.T) {
path := filepath.Join(t.TempDir(), "session.json")
status := &agentv1.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: "boot-1"}
original := NewServer(ServerOptions{Mode: "mock", StatePath: path, Status: status})
require.NoError(t, original.executionJournalReady())
recovered := NewServer(ServerOptions{Mode: mode, StatePath: path, Status: status})
if recovered.executionJournalReady() == nil {
t.Fatal("mock execution state reused by another adapter mode")
}
same := NewServer(ServerOptions{Mode: "mock", StatePath: path, Status: status})
require.NoError(t, same.executionJournalReady())
})
}
}