From 1695795aa25d6d2cf2be84fed3c063f66cf4cc70 Mon Sep 17 00:00:00 2001 From: fabriciojs Date: Sat, 28 Oct 2023 14:07:21 -0300 Subject: [PATCH 1/3] improve kool status output - fetch all services even if no container --- commands/status.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/status.go b/commands/status.go index 32f82246..87aecf34 100644 --- a/commands/status.go +++ b/commands/status.go @@ -50,7 +50,7 @@ func NewKoolStatus() *KoolStatus { checker.NewChecker(defaultKoolService.shell), network.NewHandler(defaultKoolService.shell), environment.NewEnvStorage(), - builder.NewCommand("docker", "compose", "ps", "--all", "--services"), + builder.NewCommand("docker", "compose", "config", "--services"), builder.NewCommand("docker", "compose", "ps", "--all", "--quiet"), builder.NewCommand("docker", "ps", "--all", "--format", "{{.Status}}|{{.Ports}}"), shell.NewTableWriter(), @@ -65,7 +65,9 @@ func (s *KoolStatus) Execute(args []string) (err error) { return } - if services, err = s.getServices(); err != nil || len(services) == 0 { + if services, err = s.getServices(); err != nil { + return + } else if len(services) == 0 { s.Shell().Warning("No services found.") return } From 3993899507d5d6d23d018134a87a7e1181a5d519 Mon Sep 17 00:00:00 2001 From: fabriciojs Date: Sat, 28 Oct 2023 14:43:07 -0300 Subject: [PATCH 2/3] fix test --- commands/status_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/commands/status_test.go b/commands/status_test.go index 04ec2925..652b6d6c 100644 --- a/commands/status_test.go +++ b/commands/status_test.go @@ -166,13 +166,30 @@ func TestFailedGetServicesStatusCommand(t *testing.T) { assertExecGotError(t, cmd, "exec err") - expected := "No services found." + expected := "" output := fmt.Sprint(f.shell.(*shell.FakeShell).WarningOutput...) if output != expected { t.Errorf("Expected '%s', got '%s'", expected, output) } + + f.getServicesCmd.(*builder.FakeCommand).MockExecError = nil + + if err := cmd.Execute(); err != nil { + t.Errorf("unexpected error: %v", err) + } + + fmt.Println("outputs", f.shell.(*shell.FakeShell).WarningOutput, f.shell.(*shell.FakeShell).OutLines, f.shell.(*shell.FakeShell).SuccessOutput) + t.Error("error") + + expected = "No services found." + + output = fmt.Sprint(f.shell.(*shell.FakeShell).WarningOutput...) + + if output != expected { + t.Errorf("Expected '%s', got '%s'", expected, output) + } } func TestFailedDependenciesStatusCommand(t *testing.T) { From d6430dd88ffd293ab895b13d0770e495a2e61245 Mon Sep 17 00:00:00 2001 From: fabriciojs Date: Sat, 28 Oct 2023 14:59:23 -0300 Subject: [PATCH 3/3] fix test --- commands/status_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/commands/status_test.go b/commands/status_test.go index 652b6d6c..8fc87fb4 100644 --- a/commands/status_test.go +++ b/commands/status_test.go @@ -180,9 +180,6 @@ func TestFailedGetServicesStatusCommand(t *testing.T) { t.Errorf("unexpected error: %v", err) } - fmt.Println("outputs", f.shell.(*shell.FakeShell).WarningOutput, f.shell.(*shell.FakeShell).OutLines, f.shell.(*shell.FakeShell).SuccessOutput) - t.Error("error") - expected = "No services found." output = fmt.Sprint(f.shell.(*shell.FakeShell).WarningOutput...)