(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestMigrate(t *testing.T) { |
| 14 | configs := []struct { |
| 15 | name string |
| 16 | config string |
| 17 | err string |
| 18 | }{ |
| 19 | { |
| 20 | name: "sync_success_sourcev1_destv0", |
| 21 | config: "sync-success-sourcev1-destv0.yml", |
| 22 | }, |
| 23 | { |
| 24 | name: "multiple_sources", |
| 25 | config: "multiple-sources.yml", |
| 26 | }, |
| 27 | { |
| 28 | name: "multiple_destinations", |
| 29 | config: "multiple-destinations.yml", |
| 30 | }, |
| 31 | { |
| 32 | name: "multiple_sources_destinations", |
| 33 | config: "multiple-sources-destinations.yml", |
| 34 | }, |
| 35 | { |
| 36 | name: "should fail with missing path error when path is missing", |
| 37 | config: "sync-missing-path-error.yml", |
| 38 | err: "Error: failed to validate destination test: path is required", |
| 39 | }, |
| 40 | } |
| 41 | _, filename, _, _ := runtime.Caller(0) |
| 42 | currentDir := path.Dir(filename) |
| 43 | |
| 44 | for _, tc := range configs { |
| 45 | t.Run(tc.name, func(t *testing.T) { |
| 46 | testConfig := path.Join(currentDir, "testdata", tc.config) |
| 47 | cmd := NewCmdRoot() |
| 48 | baseArgs := testCommandArgs(t) |
| 49 | cmd.SetArgs(append([]string{"migrate", testConfig}, baseArgs...)) |
| 50 | err := cmd.Execute() |
| 51 | if tc.err != "" { |
| 52 | assert.Contains(t, err.Error(), tc.err) |
| 53 | } else { |
| 54 | assert.NoError(t, err) |
| 55 | } |
| 56 | |
| 57 | // check that log was written and contains some lines from the plugin |
| 58 | b, logFileError := os.ReadFile(baseArgs[3]) |
| 59 | logContent := string(b) |
| 60 | require.NoError(t, logFileError, "failed to read cloudquery.log") |
| 61 | require.NotEmpty(t, logContent, "cloudquery.log empty; expected some logs") |
| 62 | }) |
| 63 | } |
| 64 | } |
nothing calls this directly
no test coverage detected