(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestValidateConfig(t *testing.T) { |
| 17 | configs := []struct { |
| 18 | name string |
| 19 | config string |
| 20 | errors []string |
| 21 | }{ |
| 22 | { |
| 23 | name: "multiple test sources should pass validation", |
| 24 | config: "multiple-sources.yml", |
| 25 | }, |
| 26 | { |
| 27 | name: "bad AWS and Postgres auth should fail validation", |
| 28 | config: "validate-config-error.yml", |
| 29 | errors: []string{"failed to validate source config cloudflare", "failed to validate destination config postgresql"}, |
| 30 | }, |
| 31 | } |
| 32 | _, filename, _, _ := runtime.Caller(0) |
| 33 | currentDir := path.Dir(filename) |
| 34 | |
| 35 | for _, tc := range configs { |
| 36 | t.Run(tc.name, func(t *testing.T) { |
| 37 | cmd := NewCmdRoot() |
| 38 | testConfig := path.Join(currentDir, "testdata", tc.config) |
| 39 | baseArgs := testCommandArgs(t) |
| 40 | |
| 41 | args := append([]string{"validate-config", testConfig}, baseArgs...) |
| 42 | cmd.SetArgs(args) |
| 43 | err := cmd.Execute() |
| 44 | // check that log was written and contains some lines from the plugin |
| 45 | b, logFileError := os.ReadFile(baseArgs[3]) |
| 46 | logContent := string(b) |
| 47 | require.NoError(t, logFileError, "failed to read cloudquery.log") |
| 48 | require.NotEmpty(t, logContent, "cloudquery.log empty; expected some logs") |
| 49 | require.NotContains(t, logContent, "skipping validation") |
| 50 | |
| 51 | if tc.errors != nil { |
| 52 | for _, e := range tc.errors { |
| 53 | require.Contains(t, err.Error(), e) |
| 54 | } |
| 55 | } else { |
| 56 | require.NoError(t, err) |
| 57 | } |
| 58 | }) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | func TestSplitHubPath(t *testing.T) { |
| 63 | team, name, err := splitHubPath("cloudquery/aws") |
nothing calls this directly
no test coverage detected