Skip to content

Commit

Permalink
Cleanup tests and sources about experimental mode
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Mar 1, 2023
1 parent 5f12466 commit 2621fdf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pkg/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func ListAllComponents(client kclient.ClientInterface, podmanClient podman.Clien
allComponents = append(allComponents, clusterComponents...)
}

// PdomanClient can be nil if experimental mode is not active
// PdomanClient can be nil if podman platform is not accessible
if podmanClient != nil {
podmanComponents, err := podmanClient.ListAllComponents()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/odo/commonflags/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func UsePlatformFlag(cmd *cobra.Command) {
// package
func AddPlatformFlag(ctx context.Context) {
if feature.IsEnabled(ctx, feature.GenericPlatformFlag) {
flag.CommandLine.String(PlatformFlagName, "", `Specify target platform, supported platforms: "cluster" (default), "podman" (experimental)`)
flag.CommandLine.String(PlatformFlagName, "", `Specify target platform, supported platforms: "cluster" (default), "podman"`)
_ = pflag.CommandLine.MarkHidden(PlatformFlagName)
}
}
Expand All @@ -50,7 +50,7 @@ func CheckPlatformCommand(cmd *cobra.Command) error {

// Check the valid output
if hasFlagChanged && platformFlag.Value.String() != PlatformPodman && platformFlag.Value.String() != PlatformCluster {
return fmt.Errorf(`%s is not a valid target platform for --platform, please select either "cluster" (default) or "podman" (experimental)`, platformFlag.Value.String())
return fmt.Errorf(`%s is not a valid target platform for --platform, please select either "cluster" (default) or "podman"`, platformFlag.Value.String())
}

// Check that if -o json has been passed, that the command actually USES json.. if not, error out.
Expand Down
2 changes: 1 addition & 1 deletion pkg/odo/commonflags/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestUsePlatformFlagWrongValue(t *testing.T) {
t.Errorf("Set error should be nil but is %v", err)
}
err = CheckPlatformCommand(cmd)
if err.Error() != `wrong-value is not a valid target platform for --platform, please select either "cluster" (default) or "podman" (experimental)` {
if err.Error() != `wrong-value is not a valid target platform for --platform, please select either "cluster" (default) or "podman"` {
t.Errorf("Check error is %v", err)
}
}
8 changes: 4 additions & 4 deletions tests/integration/cmd_describe_component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ var _ = Describe("odo describe component command tests", func() {

Context("Default output", func() {

When("describing the component in dev mode and with the experimental mode enabled", func() {
When("describing the component in dev mode", func() {
var stdout string
BeforeEach(func() {
stdout = helper.Cmd("odo", "describe", "component").ShouldPass().Out()
Expand Down Expand Up @@ -282,7 +282,7 @@ var _ = Describe("odo describe component command tests", func() {
Expect(err).NotTo(HaveOccurred())
})

When("describing the component from another directory and with the experimental mode enabled", func() {
When("describing the component from another directory", func() {
var stdout string
BeforeEach(func() {
stdout = helper.Cmd("odo", "describe", "component", "--name", cmpName).
Expand All @@ -309,7 +309,7 @@ var _ = Describe("odo describe component command tests", func() {

Context("JSON output", func() {

When("describing the component in dev mode and with the experimental mode enabled", func() {
When("describing the component in dev mode", func() {
var stdout, stderr string
BeforeEach(func() {
stdout, stderr = helper.Cmd("odo", "describe", "component", "-o", "json").
Expand Down Expand Up @@ -370,7 +370,7 @@ var _ = Describe("odo describe component command tests", func() {
Expect(err).NotTo(HaveOccurred())
})

When("describing the component from another directory and with the experimental mode enabled", func() {
When("describing the component from another directory", func() {
var stdout, stderr string
BeforeEach(func() {
stdout, stderr = helper.Cmd("odo", "describe", "component", "--name", cmpName, "-o", "json").
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/cmd_devfile_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ var _ = Describe("odo list with devfile", func() {
})
}

It("should display platform depending on experimental mode", func() {
It("should display platform", func() {
for _, cmd := range [][]string{
{"list", "component"},
{"list"},
} {
cmd := cmd
By("returning platform when experimental mode is enabled with json output", func() {
By("returning platform with json output", func() {
args := append(cmd, "-o", "json")
res := helper.Cmd("odo", args...).ShouldPass()
stdout, stderr := res.Out(), res.Err()
Expand All @@ -163,7 +163,7 @@ var _ = Describe("odo list with devfile", func() {
helper.JsonPathContentIs(stdout, "components.0.runningOn", "cluster") // Deprecated
helper.JsonPathContentIs(stdout, "components.0.platform", "cluster")
})
By("displaying platform when experimental mode is enabled", func() {
By("displaying platform", func() {
stdout := helper.Cmd("odo", cmd...).ShouldPass().Out()
Expect(stdout).To(ContainSubstring("PLATFORM"))
})
Expand Down Expand Up @@ -241,13 +241,13 @@ var _ = Describe("odo list with devfile", func() {
devSession.WaitEnd()
})

It("should display component depending on experimental mode and platform flag", func() {
It("should display component depending on platform flag", func() {
for _, cmd := range [][]string{
{"list", "component"},
{"list"},
} {
cmd := cmd
By("returning component in dev mode when experimental mode is enabled with json output", func() {
By("returning component in dev mode with json output", func() {
args := append(cmd, "-o", "json")
stdout := helper.Cmd("odo", args...).ShouldPass().Out()
Expect(helper.IsJSON(stdout)).To(BeTrue(), "output should be in JSON format")
Expand All @@ -257,7 +257,7 @@ var _ = Describe("odo list with devfile", func() {
helper.JsonPathContentIs(stdout, "components.0.runningOn", "podman") // Deprecated
helper.JsonPathContentIs(stdout, "components.0.platform", "podman")
})
By("returning component not in dev mode when experimental mode is enabled with json output and platform is cluster", func() {
By("returning component not in dev mode with json output and platform is cluster", func() {
args := append(cmd, "-o", "json", "--platform", "cluster")
stdout := helper.Cmd("odo", args...).ShouldPass().Out()
Expect(helper.IsJSON(stdout)).To(BeTrue(), "output should be in JSON format")
Expand All @@ -267,7 +267,7 @@ var _ = Describe("odo list with devfile", func() {
helper.JsonPathDoesNotExist(stdout, "components.0.runningOn") // Deprecated
helper.JsonPathDoesNotExist(stdout, "components.0.platform")
})
By("displaying component in dev mode when experimental mode is enabled", func() {
By("displaying component in dev mode", func() {
stdout := helper.Cmd("odo", cmd...).ShouldPass().Out()
Expect(stdout).To(ContainSubstring(componentName))
Expect(stdout).To(ContainSubstring("PLATFORM"))
Expand Down
9 changes: 0 additions & 9 deletions tests/integration/generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ var _ = Describe("odo generic", func() {
})

Describe("Experimental Mode", Label(helper.LabelNoCluster), func() {
experimentalFlag := "--platform"

AfterEach(func() {
helper.ResetExperimentalMode()
})
Expand All @@ -156,13 +154,6 @@ var _ = Describe("odo generic", func() {
out := helper.Cmd("odo", "version", "--client").ShouldPass().Out()
Expect(out).Should(ContainSubstring("Experimental mode enabled. Use at your own risk."))
})

It("experimental flags should be usable", func() {
By("via help output", func() {
helpOutput := helper.Cmd("odo", "help").ShouldPass().Out()
Expect(helpOutput).Should(ContainSubstring(experimentalFlag))
})
})
})
})

Expand Down

0 comments on commit 2621fdf

Please sign in to comment.