github.com/hashicorp/packer@v1.14.3/command/flag-kv/flag_strings_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package kvflag 5 6 import ( 7 "testing" 8 9 "github.com/google/go-cmp/cmp" 10 ) 11 12 func TestStringSlice_Set(t *testing.T) { 13 type args struct { 14 values []string 15 } 16 tests := []struct { 17 name string 18 s StringSlice 19 args args 20 wantStringSlice StringSlice 21 }{ 22 {"basic", StringSlice{"hey", "yo"}, args{[]string{"how", "are", "you"}}, 23 StringSlice{"hey", "yo", "how", "are", "you"}}, 24 } 25 for _, tt := range tests { 26 t.Run(tt.name, func(t *testing.T) { 27 for _, value := range tt.args.values { 28 err := tt.s.Set(value) 29 if err != nil { 30 t.Fatal(err) 31 } 32 } 33 if diff := cmp.Diff(tt.s, tt.wantStringSlice); diff != "" { 34 t.Fatal(diff) 35 } 36 }) 37 } 38 }