MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / Test_configForSourcePlugin

Function Test_configForSourcePlugin

cli/cmd/init_test.go:184–250  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

182}
183
184func Test_configForSourcePlugin(t *testing.T) {
185 testCases := []struct {
186 name string
187 source cqapi.ListPlugin
188 version *cqapi.PluginVersionDetails
189 expectedSpec func(*testing.T, *specs.SpecReader)
190 }{
191 {
192 name: "without example config",
193 source: cqapi.ListPlugin{
194 Name: "aws",
195 TeamName: "cloudquery",
196 Kind: cqapi.PluginKindSource,
197 LatestVersion: lo.ToPtr("v27.0.0"),
198 },
199 version: &cqapi.PluginVersionDetails{
200 Name: "v27.0.0",
201 },
202 expectedSpec: func(t *testing.T, sr *specs.SpecReader) {
203 require.Len(t, sr.Sources, 1)
204 require.Equal(t, "aws", sr.Sources[0].Name)
205 require.Equal(t, "cloudquery/aws", sr.Sources[0].Path)
206 require.Equal(t, "v27.0.0", sr.Sources[0].Version)
207 require.Equal(t, []string{"*"}, sr.Sources[0].Tables)
208 require.Equal(t, []string{"DESTINATION_NAME"}, sr.Sources[0].Destinations)
209 require.Len(t, sr.Sources[0].Spec, 0)
210 },
211 },
212 {
213 name: "with example config",
214 source: cqapi.ListPlugin{
215 Name: "aws",
216 TeamName: "cloudquery",
217 Kind: cqapi.PluginKindSource,
218 LatestVersion: lo.ToPtr("v27.0.0"),
219 },
220 version: &cqapi.PluginVersionDetails{
221 Name: "v27.0.0",
222 ExampleConfig: awsExample,
223 },
224 expectedSpec: func(t *testing.T, sr *specs.SpecReader) {
225 require.Len(t, sr.Sources, 1)
226 require.Equal(t, "aws", sr.Sources[0].Name)
227 require.Equal(t, "cloudquery/aws", sr.Sources[0].Path)
228 require.Equal(t, "v27.0.0", sr.Sources[0].Version)
229 require.Equal(t, []string{"aws_ec2_instances"}, sr.Sources[0].Tables)
230 require.Equal(t, []string{"DESTINATION_NAME"}, sr.Sources[0].Destinations)
231 require.Len(t, sr.Sources[0].Spec, 1)
232 require.Equal(t, json.Number("100"), sr.Sources[0].Spec["concurrency"])
233 },
234 },
235 }
236
237 for _, tc := range testCases {
238 tc := tc
239 t.Run(tc.name, func(t *testing.T) {
240 tempDir := t.TempDir()
241 specPath := path.Join(tempDir, "spec.yaml")

Callers

nothing calls this directly

Calls 2

configForSourcePluginFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected