MCPcopy Create free account
hub / github.com/devspace-sh/devspace / Test_ApplyExtraFlagsWithDevspaceFlags

Function Test_ApplyExtraFlagsWithDevspaceFlags

pkg/util/flags/flags_test.go:20–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18}
19
20func Test_ApplyExtraFlagsWithDevspaceFlags(t *testing.T) {
21 devspaceFlags := env.GlobalGetEnv("DEVSPACE_FLAGS")
22 assert.Equal(t, "", devspaceFlags, "DEVSPACE_FLAGS should be empty")
23
24 devspaceFlags = "-s --kubeconfig /path/to/kubeconfig --debug"
25 err := os.Setenv("DEVSPACE_FLAGS", devspaceFlags)
26 assert.NilError(t, err, "Error setting DEVSPACE_FLAGS")
27 mycmd := &cobra.Command{}
28 persistentFlags := mycmd.PersistentFlags()
29 _ = flags.SetGlobalFlags(persistentFlags)
30
31 flags, err := ApplyExtraFlags(mycmd, []string{}, false)
32 assert.NilError(t, err, "Error applying extra flags")
33 assert.Equal(t, 4, len(flags), "Flags should have 4 elements")
34
35 kubeconfig := env.GlobalGetEnv("KUBECONFIG")
36 assert.Equal(t, "/path/to/kubeconfig", kubeconfig, "Path should be /path/to/kubeconfig")
37}

Callers

nothing calls this directly

Calls 3

SetGlobalFlagsFunction · 0.92
ApplyExtraFlagsFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected