From 6b48feb81782fcb68003b922a77856ae871b212d Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Thu, 12 Mar 2020 16:28:23 +0100 Subject: [PATCH] kvflag: add TestStringSlice_Set --- helper/flag-kv/flag_strings_test.go | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 helper/flag-kv/flag_strings_test.go diff --git a/helper/flag-kv/flag_strings_test.go b/helper/flag-kv/flag_strings_test.go new file mode 100644 index 000000000..bc6c3af18 --- /dev/null +++ b/helper/flag-kv/flag_strings_test.go @@ -0,0 +1,32 @@ +package kvflag + +import ( + "testing" + + "github.com/google/go-cmp/cmp" +) + +func TestStringSlice_Set(t *testing.T) { + type args struct { + values []string + } + tests := []struct { + name string + s StringSlice + args args + wantStringSlice StringSlice + }{ + {"basic", StringSlice{"hey", "yo"}, args{[]string{"how", "are", "you"}}, + StringSlice{"hey", "yo", "how", "are", "you"}}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + for _, value := range tt.args.values { + tt.s.Set(value) + } + if diff := cmp.Diff(tt.s, tt.wantStringSlice); diff != "" { + t.Fatal(diff) + } + }) + } +}