feat: add b-route send adapter shell
This commit is contained in:
55
internal/tools/send_message_broute_adapter_test.go
Normal file
55
internal/tools/send_message_broute_adapter_test.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBRouteSendMessageConnectorDisabledMode(t *testing.T) {
|
||||
connector := NewBRouteSendMessageConnector(BRouteSendAdapterConfig{Mode: "disabled"})
|
||||
result, err := connector.ExecuteSendMessage(context.Background(), SendMessageConnectorRequest{
|
||||
TargetType: "direct",
|
||||
TargetID: "u1",
|
||||
TargetRef: "contact:u1",
|
||||
ContentSHA256: "abc",
|
||||
ContentLength: 3,
|
||||
IdempotencyKeySHA256: "idem",
|
||||
ExecutionMode: "production",
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatalf("expected disabled error")
|
||||
}
|
||||
if result.ErrorCode != "broute_mode_blocked" {
|
||||
t.Fatalf("unexpected error code: %s", result.ErrorCode)
|
||||
}
|
||||
if result.ConnectorMode != "broute-disabled" {
|
||||
t.Fatalf("connector mode = %q, want broute-disabled", result.ConnectorMode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBRouteSendMessageConnectorDryRunContract(t *testing.T) {
|
||||
connector := NewBRouteSendMessageConnector(BRouteSendAdapterConfig{
|
||||
SidecarPath: `Z:\path\that\must\not\be\started\SendSidecar.exe`,
|
||||
TimeoutSeconds: 5,
|
||||
Mode: "dry_run_contract",
|
||||
})
|
||||
result, err := connector.ExecuteSendMessage(context.Background(), SendMessageConnectorRequest{
|
||||
TargetType: "direct",
|
||||
TargetID: "u1",
|
||||
TargetRef: "contact:u1",
|
||||
ContentSHA256: strings.Repeat("a", 64),
|
||||
ContentLength: 3,
|
||||
IdempotencyKeySHA256: strings.Repeat("b", 64),
|
||||
ExecutionMode: "production",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("dry-run contract should not try to start a sidecar or return process error: %v", err)
|
||||
}
|
||||
if result.Accepted {
|
||||
t.Fatalf("dry-run contract must not accept a real send: %+v", result)
|
||||
}
|
||||
if result.ConnectorMode != "broute-dry-run-contract" || result.ErrorCode != "broute_dry_run_only" {
|
||||
t.Fatalf("unexpected dry-run result: %+v", result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user