mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-27 21:33:41 +02:00
* feat: add daemon websocket task wakeups * feat: fan out daemon wakeups across nodes * fix: dedupe daemon wakeup loopback events * fix: lengthen daemon polling fallback interval --------- Co-authored-by: Eve <eve@multica.ai>
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package daemon
|
|
|
|
import "testing"
|
|
|
|
func TestTaskWakeupURL(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
baseURL string
|
|
runtimeIDs []string
|
|
want string
|
|
}{
|
|
{
|
|
name: "http base",
|
|
baseURL: "http://localhost:8080",
|
|
runtimeIDs: []string{"runtime-b", "runtime-a"},
|
|
want: "ws://localhost:8080/api/daemon/ws?runtime_ids=runtime-a%2Cruntime-b",
|
|
},
|
|
{
|
|
name: "https base",
|
|
baseURL: "https://api.example.com",
|
|
runtimeIDs: []string{"runtime-1"},
|
|
want: "wss://api.example.com/api/daemon/ws?runtime_ids=runtime-1",
|
|
},
|
|
{
|
|
name: "base path",
|
|
baseURL: "https://api.example.com/multica",
|
|
runtimeIDs: []string{"runtime-1"},
|
|
want: "wss://api.example.com/multica/api/daemon/ws?runtime_ids=runtime-1",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := taskWakeupURL(tt.baseURL, tt.runtimeIDs)
|
|
if err != nil {
|
|
t.Fatalf("taskWakeupURL: %v", err)
|
|
}
|
|
if got != tt.want {
|
|
t.Fatalf("taskWakeupURL() = %q, want %q", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|