(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func Test_ValidateExportConfigFlags(t *testing.T) { |
| 11 | tests := []struct { |
| 12 | name string |
| 13 | opts ExportOptions |
| 14 | wantsErr bool |
| 15 | wantsErrMsg string |
| 16 | }{ |
| 17 | { |
| 18 | name: "No existing indice", |
| 19 | opts: ExportOptions{ |
| 20 | Index: "INDEX_1", |
| 21 | Scope: []string{"settings", "rules", "synonyms"}, |
| 22 | Indices: []string{}, |
| 23 | }, |
| 24 | wantsErr: true, |
| 25 | wantsErrMsg: "X Index 'INDEX_1' doesn't exist", |
| 26 | }, |
| 27 | { |
| 28 | name: "Full scope with existing indices", |
| 29 | opts: ExportOptions{ |
| 30 | Index: "INDEX_1", |
| 31 | Scope: []string{"settings", "rules", "synonyms"}, |
| 32 | Indices: []string{"INDEX_1", "INDEX_2"}, |
| 33 | }, |
| 34 | wantsErr: false, |
| 35 | }, |
| 36 | { |
| 37 | name: "Full score, existing indices with directory", |
| 38 | opts: ExportOptions{ |
| 39 | Index: "INDEX_1", |
| 40 | Scope: []string{"settings", "rules", "synonyms"}, |
| 41 | Indices: []string{"INDEX_1", "INDEX_2"}, |
| 42 | Directory: "test/folder", |
| 43 | }, |
| 44 | wantsErr: false, |
| 45 | }, |
| 46 | } |
| 47 | |
| 48 | for _, tt := range tests { |
| 49 | t.Run(tt.name, func(t *testing.T) { |
| 50 | io, _, _, _ := iostreams.Test() |
| 51 | tt.opts.IO = io |
| 52 | |
| 53 | err := ValidateExportConfigFlags(tt.opts) |
| 54 | |
| 55 | if tt.wantsErr { |
| 56 | assert.EqualError(t, err, tt.wantsErrMsg) |
| 57 | return |
| 58 | } |
| 59 | }) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func Test_ValidateImportConfigFlags(t *testing.T) { |
| 64 | tests := []struct { |
nothing calls this directly
no test coverage detected