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

Function Test_configForDestinationPlugin

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

Source from the content-addressed store, hash-verified

250}
251
252func Test_configForDestinationPlugin(t *testing.T) {
253 testCases := []struct {
254 name string
255 destination cqapi.ListPlugin
256 version *cqapi.PluginVersionDetails
257 expectedSpec func(*testing.T, *specs.SpecReader)
258 }{
259 {
260 name: "without example config",
261 destination: cqapi.ListPlugin{
262 Name: "postgresql",
263 TeamName: "cloudquery",
264 Kind: cqapi.PluginKindDestination,
265 LatestVersion: lo.ToPtr("v8.0.0"),
266 },
267 version: &cqapi.PluginVersionDetails{
268 Name: "v8.0.0",
269 },
270 expectedSpec: func(t *testing.T, sr *specs.SpecReader) {
271 require.Len(t, sr.Destinations, 1)
272 require.Equal(t, "postgresql", sr.Destinations[0].Name)
273 require.Equal(t, "cloudquery/postgresql", sr.Destinations[0].Path)
274 require.Equal(t, "v8.0.0", sr.Destinations[0].Version)
275 require.Len(t, sr.Destinations[0].Spec, 0)
276 },
277 },
278 {
279 name: "with example config",
280 destination: cqapi.ListPlugin{
281 Name: "postgresql",
282 TeamName: "cloudquery",
283 Kind: cqapi.PluginKindDestination,
284 LatestVersion: lo.ToPtr("v8.0.0"),
285 },
286 version: &cqapi.PluginVersionDetails{
287 Name: "v8.0.0",
288 ExampleConfig: postgresqlExample,
289 },
290 expectedSpec: func(t *testing.T, sr *specs.SpecReader) {
291 require.Len(t, sr.Destinations, 1)
292 require.Equal(t, "postgresql", sr.Destinations[0].Name)
293 require.Equal(t, "cloudquery/postgresql", sr.Destinations[0].Path)
294 require.Equal(t, "v8.0.0", sr.Destinations[0].Version)
295 require.Len(t, sr.Destinations[0].Spec, 1)
296 require.Equal(t, "test", sr.Destinations[0].Spec["connection_string"])
297 },
298 },
299 }
300
301 // Set environment variables so the spec reader doesn't fail
302 t.Setenv("POSTGRESQL_CONNECTION_STRING", "test")
303 for _, tc := range testCases {
304 tc := tc
305 t.Run(tc.name, func(t *testing.T) {
306 tempDir := t.TempDir()
307 specPath := path.Join(tempDir, "spec.yaml")
308 spec := configForDestinationPlugin(tc.destination, tc.version)
309 require.NoError(t, os.WriteFile(specPath, []byte(spec), 0644))

Callers

nothing calls this directly

Calls 2

RunMethod · 0.80

Tested by

no test coverage detected