From 08c84d81ca940dd1b8bdffcbe8097779138b28d0 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 30 Mar 2023 03:35:03 +0200 Subject: [PATCH] transport/channel_test.go: Add test for Channel.Is() --- transport/channel_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/transport/channel_test.go b/transport/channel_test.go index 9301c31..b326ffb 100644 --- a/transport/channel_test.go +++ b/transport/channel_test.go @@ -25,6 +25,33 @@ func TestChannel_Append(t *testing.T) { } } +func TestChannel_Is(t *testing.T) { + tests := []struct { + name string + a Channel + b Channel + want bool + }{ + {"Empty valid", Channel{}, Channel{}, true}, + {"Valid #1", Channel{"one"}, Channel{"one"}, true}, + {"Valid #2", Channel{"one", "two"}, Channel{"one", "two"}, true}, + {"Invalid #1", Channel{"one"}, Channel{"one", "two"}, false}, + {"Invalid #2", Channel{"one", "three"}, Channel{"one", "two"}, false}, + {"Invalid #3", Channel{"two", "one"}, Channel{"one", "two"}, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.a.Is(tt.b); got != tt.want { + t.Errorf("a.Is(b) = %v, want %v", got, tt.want) + } + + if got := tt.b.Is(tt.a); got != tt.want { + t.Errorf("b.Is(a) = %v, want %v", got, tt.want) + } + }) + } +} + func TestChannel_String(t *testing.T) { tests := []struct { name string