File: flag_strings_test.go

package info (click to toggle)
packer 1.6.6%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 32,016 kB
  • sloc: sh: 1,154; python: 619; makefile: 251; ruby: 205; xml: 97
file content (35 lines) | stat: -rw-r--r-- 696 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 {
				err := tt.s.Set(value)
				if err != nil {
					t.Fatal(err)
				}
			}
			if diff := cmp.Diff(tt.s, tt.wantStringSlice); diff != "" {
				t.Fatal(diff)
			}
		})
	}
}