diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-10 23:02:37 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-10 23:02:37 +0300 |
| commit | 5b8deb6658b06625f50c35a07c507e02a0bbe074 (patch) | |
| tree | a83cd2316a9667e7384d4019a3f127112e9f28c7 /internal/server/handlers/protocol_codec_test.go | |
| parent | c6629d2a35c744c3a605c725b40f21c6656a2fd8 (diff) | |
task 80: fix protocol compatibility parsing
Diffstat (limited to 'internal/server/handlers/protocol_codec_test.go')
| -rw-r--r-- | internal/server/handlers/protocol_codec_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/server/handlers/protocol_codec_test.go b/internal/server/handlers/protocol_codec_test.go new file mode 100644 index 0000000..a182d18 --- /dev/null +++ b/internal/server/handlers/protocol_codec_test.go @@ -0,0 +1,32 @@ +package handlers + +import ( + "strings" + "testing" + + "github.com/mimecast/dtail/internal/protocol" +) + +func TestHandleProtocolVersionUsesSemanticCompatComparison(t *testing.T) { + codec := newProtocolCodec(nil) + + args, argc, add, err := codec.handleProtocolVersion([]string{"protocol", "4", "tail", "payload"}) + if err == nil { + t.Fatal("expected protocol mismatch error") + } + if argc != 4 { + t.Fatalf("unexpected argc: got %d want 4", argc) + } + if len(args) != 4 || args[0] != "protocol" || args[1] != "4" { + t.Fatalf("unexpected args returned: %#v", args) + } + if add != "" { + t.Fatalf("unexpected message separator: %q", add) + } + if !strings.Contains(err.Error(), "please update DTail client") { + t.Fatalf("expected client update guidance, got %q", err) + } + if !strings.Contains(err.Error(), protocol.ProtocolCompat) { + t.Fatalf("expected error to mention server protocol version, got %q", err) + } +} |
