diff options
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) + } +} |
