Skip to content

Commit a0a5b5b

Browse files
authored
Merge pull request #480 from kool-dev/kool-status-tweaks
`kool status` improvement
2 parents d9a915b + d6430dd commit a0a5b5b

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

commands/status.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func NewKoolStatus() *KoolStatus {
5050
checker.NewChecker(defaultKoolService.shell),
5151
network.NewHandler(defaultKoolService.shell),
5252
environment.NewEnvStorage(),
53-
builder.NewCommand("docker", "compose", "ps", "--all", "--services"),
53+
builder.NewCommand("docker", "compose", "config", "--services"),
5454
builder.NewCommand("docker", "compose", "ps", "--all", "--quiet"),
5555
builder.NewCommand("docker", "ps", "--all", "--format", "{{.Status}}|{{.Ports}}"),
5656
shell.NewTableWriter(),
@@ -65,7 +65,9 @@ func (s *KoolStatus) Execute(args []string) (err error) {
6565
return
6666
}
6767

68-
if services, err = s.getServices(); err != nil || len(services) == 0 {
68+
if services, err = s.getServices(); err != nil {
69+
return
70+
} else if len(services) == 0 {
6971
s.Shell().Warning("No services found.")
7072
return
7173
}

commands/status_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,27 @@ func TestFailedGetServicesStatusCommand(t *testing.T) {
166166

167167
assertExecGotError(t, cmd, "exec err")
168168

169-
expected := "No services found."
169+
expected := ""
170170

171171
output := fmt.Sprint(f.shell.(*shell.FakeShell).WarningOutput...)
172172

173173
if output != expected {
174174
t.Errorf("Expected '%s', got '%s'", expected, output)
175175
}
176+
177+
f.getServicesCmd.(*builder.FakeCommand).MockExecError = nil
178+
179+
if err := cmd.Execute(); err != nil {
180+
t.Errorf("unexpected error: %v", err)
181+
}
182+
183+
expected = "No services found."
184+
185+
output = fmt.Sprint(f.shell.(*shell.FakeShell).WarningOutput...)
186+
187+
if output != expected {
188+
t.Errorf("Expected '%s', got '%s'", expected, output)
189+
}
176190
}
177191

178192
func TestFailedDependenciesStatusCommand(t *testing.T) {

0 commit comments

Comments
 (0)