feat: improve channel resilience and operations
This commit is contained in:
@@ -140,6 +140,39 @@ func TestConnectChannelRejectsInvalidCommand(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisconnectChannelStopsSupplierPool(t *testing.T) {
|
||||
var received DisconnectChannelCommand
|
||||
handler := handlerWithServer(Server{
|
||||
Disconnect: func(_ context.Context, command DisconnectChannelCommand) (ConnectionStateCallback, error) {
|
||||
received = command
|
||||
return ConnectionStateCallback{
|
||||
ChannelID: command.ChannelID,
|
||||
ConnectionID: command.ConnectionID,
|
||||
Status: "disconnected",
|
||||
CurrentConnections: 0,
|
||||
}, nil
|
||||
},
|
||||
})
|
||||
resp := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodPost, "/connections/disconnect", strings.NewReader(`{
|
||||
"schemaVersion":"v1",
|
||||
"messageType":"DisconnectChannel",
|
||||
"traceId":"trace-disconnect",
|
||||
"channelId":"channel-1",
|
||||
"connectionId":"channel-1:primary",
|
||||
"reason":"channel_disabled"
|
||||
}`))
|
||||
|
||||
handler.ServeHTTP(resp, req)
|
||||
|
||||
if resp.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected response status: %d body=%s", resp.Code, resp.Body.String())
|
||||
}
|
||||
if received.ChannelID != "channel-1" || received.Reason != "channel_disabled" {
|
||||
t.Fatalf("unexpected disconnect command: %+v", received)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecoveryCandidatesEndpointReturnsView(t *testing.T) {
|
||||
handler := handlerWithServer(Server{
|
||||
RecoveryCandidates: func(context.Context) ([]inbound.DownstreamPresence, error) {
|
||||
|
||||
Reference in New Issue
Block a user