MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / TestTablesWithFilter

Function TestTablesWithFilter

cli/cmd/tables_test.go:72–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestTablesWithFilter(t *testing.T) {
73 configs := []struct {
74 name string
75 config string
76 filter string
77 }{
78 {
79 name: "should generate tables in default format",
80 config: "cloudflare-tables-with-spec-filter.yml",
81 },
82 {
83 name: "should generate tables in json format",
84 config: "cloudflare-tables-with-spec-filter.yml",
85 filter: "spec",
86 },
87 }
88
89 for _, tc := range configs {
90 t.Run(tc.name, func(t *testing.T) {
91 cmd, docsDir := getTablesCommand(t, tc.config, "json", tc.filter)
92 commandError := cmd.Execute()
93 require.NoError(t, commandError)
94 expectedFile := path.Join(docsDir, "cq-docs/cloudflare/__tables.json")
95 require.FileExists(t, expectedFile)
96 file, err := os.Open(expectedFile)
97 require.NoError(t, err)
98 content, err := io.ReadAll(file)
99 require.NoError(t, err)
100 _ = file.Close()
101 type table struct {
102 Name string `json:"name"`
103 }
104 var tables []table
105 err = json.Unmarshal(content, &tables)
106 require.NoError(t, err)
107
108 if tc.filter == "spec" {
109 require.Len(t, tables, 1)
110 require.Equal(t, "cloudflare_access_applications", tables[0].Name)
111 } else {
112 require.Greater(t, len(tables), 1)
113 }
114 })
115 }
116}

Callers

nothing calls this directly

Calls 3

getTablesCommandFunction · 0.85
RunMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected