(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func Test_pluginFlag_Set(t *testing.T) { |
| 14 | tests := []struct { |
| 15 | name string |
| 16 | args string |
| 17 | wantErr bool |
| 18 | want [][]string |
| 19 | }{ |
| 20 | { |
| 21 | name: "test plugin flag", |
| 22 | args: "geoip,db=/Users/test/test.mmdb", |
| 23 | wantErr: false, |
| 24 | want: [][]string{ |
| 25 | {"geoip", "db=/Users/test/test.mmdb"}, |
| 26 | }, |
| 27 | }, |
| 28 | { |
| 29 | name: "test plugin flag with two plugins", |
| 30 | args: "geoip,db=/Users/test/test.mmdb inet,timeout=1000,delay=2000", |
| 31 | wantErr: false, |
| 32 | want: [][]string{ |
| 33 | {"geoip", "db=/Users/test/test.mmdb"}, |
| 34 | {"inet", "timeout=1000", "delay=2000"}, |
| 35 | }, |
| 36 | }, |
| 37 | } |
| 38 | for _, tt := range tests { |
| 39 | t.Run(tt.name, func(t *testing.T) { |
| 40 | pf := newPluginFlag() |
| 41 | |
| 42 | if err := pf.Set(tt.args); (err != nil) != tt.wantErr { |
| 43 | t.Errorf("pluginFlag.Set() error = %v, wantErr %v", err, tt.wantErr) |
| 44 | } |
| 45 | |
| 46 | if !tt.wantErr { |
| 47 | // sort lists because the order of pf.values is not guaranteed |
| 48 | sortFlags(pf.values) |
| 49 | sortFlags(tt.want) |
| 50 | if cmp.Equal(pf.values, tt.want) == false { |
| 51 | t.Errorf("pluginFlag.Set() got v, want v, %v", cmp.Diff(pf.values, tt.want)) |
| 52 | } |
| 53 | } |
| 54 | }) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func Test_pluginFlag_UnmarshalYAML(t *testing.T) { |
| 59 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…