Skip to content

Commit

Permalink
Test a msg is displayed when executing odo run without odo dev
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Jun 1, 2023
1 parent 1fdda50 commit 8c6f335
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/dev/common/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func Run(

pod, err := platformClient.GetPodUsingComponentName(componentName)
if err != nil {
return fmt.Errorf("unable to get pod for component %s: %w", componentName, err)
return fmt.Errorf("unable to get pod for component %s: %w. Please check the command odo dev is running", componentName, err)
}

handler := component.NewRunHandler(
Expand Down
27 changes: 21 additions & 6 deletions tests/integration/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ var _ = Describe("odo run command tests", func() {
})
})

It("should fail if odo dev is not running", func() {
output := helper.Cmd("odo", "run", "build").ShouldFail().Err()
Expect(output).To(ContainSubstring(`unable to get pod for component`))
Expect(output).To(ContainSubstring(`Please check the command odo dev is running`))
})

for _, podman := range []bool{false, true} {
podman := podman
When("odo dev is executed and ready", helper.LabelPodmanIf(podman, func() {
Expand Down Expand Up @@ -112,12 +118,21 @@ var _ = Describe("odo run command tests", func() {
})
}

By("executing apply command on Image component", func() {
// Will fail because Dockerfile is not present, but we just want to check the build is started
// We cannot use PODMAN_CMD=echo with --platform=podman
output := helper.Cmd("odo", "run", "build-image", "--platform", platform).ShouldFail().Out()
Expect(output).To(ContainSubstring("Building image locally"))
})
if podman {
By("executing apply command on Image component", func() {
// Will fail because Dockerfile is not present, but we just want to check the build is started
// We cannot use PODMAN_CMD=echo with --platform=podman
output := helper.Cmd("odo", "run", "build-image", "--platform", platform).ShouldFail().Out()
Expect(output).To(ContainSubstring("Building image locally"))
})
} else {
By("executing apply command on Image component", func() {
output := helper.Cmd("odo", "run", "build-image", "--platform", platform).AddEnv("PODMAN_CMD=echo").ShouldPass().Out()
Expect(output).To(ContainSubstring("Building image locally"))
Expect(output).To(ContainSubstring("Pushing image to container registry"))

})
}
})
}))
}
Expand Down

0 comments on commit 8c6f335

Please sign in to comment.