Skip to content

Commit 8c6f335

Browse files
committed
Test a msg is displayed when executing odo run without odo dev
1 parent 1fdda50 commit 8c6f335

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

Diff for: pkg/dev/common/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Run(
3030

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

3636
handler := component.NewRunHandler(

Diff for: tests/integration/cmd_run_test.go

+21-6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ var _ = Describe("odo run command tests", func() {
7070
})
7171
})
7272

73+
It("should fail if odo dev is not running", func() {
74+
output := helper.Cmd("odo", "run", "build").ShouldFail().Err()
75+
Expect(output).To(ContainSubstring(`unable to get pod for component`))
76+
Expect(output).To(ContainSubstring(`Please check the command odo dev is running`))
77+
})
78+
7379
for _, podman := range []bool{false, true} {
7480
podman := podman
7581
When("odo dev is executed and ready", helper.LabelPodmanIf(podman, func() {
@@ -112,12 +118,21 @@ var _ = Describe("odo run command tests", func() {
112118
})
113119
}
114120

115-
By("executing apply command on Image component", func() {
116-
// Will fail because Dockerfile is not present, but we just want to check the build is started
117-
// We cannot use PODMAN_CMD=echo with --platform=podman
118-
output := helper.Cmd("odo", "run", "build-image", "--platform", platform).ShouldFail().Out()
119-
Expect(output).To(ContainSubstring("Building image locally"))
120-
})
121+
if podman {
122+
By("executing apply command on Image component", func() {
123+
// Will fail because Dockerfile is not present, but we just want to check the build is started
124+
// We cannot use PODMAN_CMD=echo with --platform=podman
125+
output := helper.Cmd("odo", "run", "build-image", "--platform", platform).ShouldFail().Out()
126+
Expect(output).To(ContainSubstring("Building image locally"))
127+
})
128+
} else {
129+
By("executing apply command on Image component", func() {
130+
output := helper.Cmd("odo", "run", "build-image", "--platform", platform).AddEnv("PODMAN_CMD=echo").ShouldPass().Out()
131+
Expect(output).To(ContainSubstring("Building image locally"))
132+
Expect(output).To(ContainSubstring("Pushing image to container registry"))
133+
134+
})
135+
}
121136
})
122137
}))
123138
}

0 commit comments

Comments
 (0)