Repository: supabase/cli
Pull request #785 (2023-01-11 11:21:26)

fix: report excluded containers with status command
## What kind of change does this PR introduce?

Bug fix

## What is the current behavior?

`supabase status` errors if a container is excluded from start

## What is the new behavior?

since `supabase start` now waits for services to be healthy, we can change `supabase status` to print stopped services to stderr

## Additional context

Add any other context or screenshots.



Patch:
diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go
index a796d583..85685205 100644
--- a/internal/db/reset/reset.go
+++ b/internal/db/reset/reset.go
@@ -13,6 +13,7 @@ import (
 	"github.com/jackc/pgx/v4"
 	"github.com/spf13/afero"
 	"github.com/supabase/cli/internal/db/diff"
+	"github.com/supabase/cli/internal/status"
 	"github.com/supabase/cli/internal/utils"
 	"github.com/supabase/cli/internal/utils/parser"
 )
@@ -164,14 +165,9 @@ func RetryEverySecond(callback func() bool, timeout time.Duration) bool {
 	return false
 }
 
-func IsContainerHealthy(ctx context.Context, container string) bool {
-	resp, err := utils.Docker.ContainerInspect(ctx, container)
-	return err == nil && resp.State.Health != nil && resp.State.Health.Status == "healthy"
-}
-
 func WaitForHealthyService(ctx context.Context, container string, timeout time.Duration) bool {
 	probe := func() bool {
-		return IsContainerHealthy(ctx, container)
+		return status.AssertContainerHealthy(ctx, container) == nil
 	}
 	return RetryEverySecond(probe, timeout)
 }
diff --git a/internal/start/start.go b/internal/start/start.go
index 4e1bf5e3..fb9af7ce 100644
--- a/internal/start/start.go
+++ b/internal/start/start.go
@@ -6,7 +6,6 @@ import (
 	_ "embed"
 	"errors"
 	"fmt"
-	"net/http"
 	"os"
 	"strconv"
 	"strings"
@@ -19,6 +18,7 @@ import (
 	"github.com/spf13/afero"
 	"github.com/supabase/cli/internal/db/reset"
 	"github.com/supabase/cli/internal/db/start"
+	"github.com/supabase/cli/internal/status"
 	"github.com/supabase/cli/internal/utils"
 )
 
@@ -46,8 +46,8 @@ func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string) error
 		return err
 	}
 
-	fmt.Println("Started " + utils.Aqua("supabase") + " local development setup.")
-	utils.ShowStatus()
+	fmt.Fprintf(os.Stderr, "Started %s local development setup.\n\n", utils.Aqua("supabase"))
+	status.PrettyPrint(os.Stdout, excludedContainers...)
 	return nil
 }
 
@@ -471,7 +471,7 @@ func waitForServiceReady(ctx context.Context, started []string) error {
 	probe := func() bool {
 		var unhealthy []string
 		for _, container := range started {
-			if !isServiceReady(ctx, container) {
+			if !status.IsServiceReady(ctx, container) {
 				unhealthy = append(unhealthy, container)
 			}
 		}
@@ -483,22 +483,3 @@ func waitForServiceReady(ctx context.Context, started []string) error {
 	}
 	return nil
 }
-
-func isServiceReady(ctx context.Context, container string) bool {
-	if container == utils.RestId {
-		return IsPostgRESTHealthy(ctx)
-	}
-	return reset.IsContainerHealthy(ctx, container)
-}
-
-func IsPostgRESTHealthy(ctx context.Context) bool {
-	// PostgREST does not support native health checks
-	restUrl := fmt.Sprintf("http://localhost:%d/rest/v1/", utils.Config.Api.Port)
-	req, err := http.NewRequestWithContext(ctx, http.MethodHead, restUrl, nil)
-	if err != nil {
-		return false
-	}
-	req.Header.Add("apikey", utils.AnonKey)
-	resp, err := http.DefaultClient.Do(req)
-	return err == nil && resp.StatusCode == http.StatusOK
-}
diff --git a/internal/status/status.go b/internal/status/status.go
index 7a0d43c0..1d910179 100644
--- a/internal/status/status.go
+++ b/internal/status/status.go
@@ -5,9 +5,12 @@ import (
 	"encoding/json"
 	"fmt"
 	"io"
+	"net/http"
 	"os"
+	"reflect"
 
 	"github.com/BurntSushi/toml"
+	"github.com/docker/docker/client"
 	"github.com/joho/godotenv"
 	"github.com/spf13/afero"
 	"github.com/supabase/cli/internal/utils"
@@ -27,19 +30,39 @@ type CustomName struct {
 	DbURL          string `env:"db.url,default=DB_URL"`
 	StudioURL      string `env:"studio.url,default=STUDIO_URL"`
 	InbucketURL    string `env:"inbucket.url,default=INBUCKET_URL"`
+	JWTSecret      string `env:"auth.jwt_secret,default=JWT_SECRET"`
 	AnonKey        string `env:"auth.anon_key,default=ANON_KEY"`
 	ServiceRoleKey string `env:"auth.service_role_key,default=SERVICE_ROLE_KEY"`
 }
 
-func (c *CustomName) toValues() map[string]string {
-	return map[string]string{
-		c.ApiURL:         fmt.Sprintf("http://localhost:%d", utils.Config.Api.Port),
-		c.DbURL:          fmt.Sprintf("postgresql://postgres:postgres@localhost:%d/postgres", utils.Config.Db.Port),
-		c.StudioURL:      fmt.Sprintf("http://localhost:%d", utils.Config.Studio.Port),
-		c.InbucketURL:    fmt.Sprintf("http://localhost:%d", utils.Config.Inbucket.Port),
-		c.AnonKey:        utils.AnonKey,
-		c.ServiceRoleKey: utils.ServiceRoleKey,
+func (c *CustomName) toValues(exclude ...string) map[string]string {
+	values := map[string]string{
+		c.DbURL: fmt.Sprintf("postgresql://postgres:postgres@localhost:%d/postgres", utils.Config.Db.Port),
 	}
+	if !sliceContains(exclude, utils.RestId) && !sliceContains(exclude, utils.ShortContainerImageName(utils.PostgrestImage)) {
+		values[c.ApiURL] = fmt.Sprintf("http://localhost:%d", utils.Config.Api.Port)
+	}
+	if !sliceContains(exclude, utils.StudioId) && !sliceContains(exclude, utils.ShortContainerImageName(utils.StudioImage)) {
+		values[c.StudioURL] = fmt.Sprintf("http://localhost:%d", utils.Config.Studio.Port)
+	}
+	if !sliceContains(exclude, utils.GotrueId) && !sliceContains(exclude, utils.ShortContainerImageName(utils.GotrueImage)) {
+		values[c.JWTSecret] = utils.JWTSecret
+		values[c.AnonKey] = utils.AnonKey
+		values[c.ServiceRoleKey] = utils.ServiceRoleKey
+	}
+	if !sliceContains(exclude, utils.InbucketId) && !sliceContains(exclude, utils.ShortContainerImageName(utils.InbucketImage)) {
+		values[c.InbucketURL] = fmt.Sprintf("http://localhost:%d", utils.Config.Inbucket.Port)
+	}
+	return values
+}
+
+func sliceContains(s []string, e string) bool {
+	for _, a := range s {
+		if a == e {
+			return true
+		}
+	}
+	return false
 }
 
 func Run(ctx context.Context, names CustomName, format string, fsys afero.Fs) error {
@@ -51,42 +74,80 @@ func Run(ctx context.Context, names CustomName, format string, fsys afero.Fs) er
 		if err := utils.LoadConfigFS(fsys); err != nil {
 			return err
 		}
-		if err := utils.AssertDockerIsRunning(); err != nil {
+		if err := AssertContainerHealthy(ctx, utils.DbId); err != nil {
 			return err
 		}
 	}
 
 	services := []string{
-		utils.DbId,
 		utils.KongId,
 		utils.GotrueId,
 		utils.InbucketId,
 		utils.RealtimeId,
 		utils.RestId,
 		utils.StorageId,
+		utils.ImgProxyId,
 		utils.PgmetaId,
 		utils.StudioId,
 	}
-	if err := checkServiceHealth(ctx, services, os.Stderr); err != nil {
-		return err
+	stopped := checkServiceHealth(ctx, services, os.Stderr)
+	if len(stopped) > 0 {
+		fmt.Fprintln(os.Stderr, "Stopped services:", stopped)
+	}
+	if format == OutputPretty {
+		fmt.Fprintf(os.Stderr, "%s local development setup is running.\n\n", utils.Aqua("supabase"))
+		PrettyPrint(os.Stdout, stopped...)
+		return nil
 	}
-	return printStatus(names.toValues(), format, os.Stdout)
+	return printStatus(names, format, os.Stdout, stopped...)
 }
 
-func checkServiceHealth(ctx context.Context, services []string, w io.Writer) error {
+func checkServiceHealth(ctx context.Context, services []string, w io.Writer) (stopped []string) {
 	for _, name := range services {
-		resp, err := utils.Docker.ContainerInspect(ctx, name)
-		if err != nil {
-			return fmt.Errorf("%s container not found. Have you run %s?", name, utils.Aqua("supabase start"))
-		}
-		if !resp.State.Running {
-			fmt.Fprintln(w, name, "container is not running:", resp.State.Status)
+		if err := AssertContainerHealthy(ctx, name); err != nil {
+			if client.IsErrNotFound(err) {
+				stopped = append(stopped, name)
+			} else {
+				// Log unhealthy containers instead of failing
+				fmt.Fprintln(w, err)
+			}
 		}
 	}
+	return stopped
+}
+
+func AssertContainerHealthy(ctx context.Context, container string) error {
+	if resp, err := utils.Docker.ContainerInspect(ctx, container); err != nil {
+		return err
+	} else if !resp.State.Running {
+		return fmt.Errorf("%s container is not running: %s", container, resp.State.Status)
+	} else if resp.State.Health != nil && resp.State.Health.Status != "healthy" {
+		return fmt.Errorf("%s container is not ready: %s", container, resp.State.Health.Status)
+	}
 	return nil
 }
 
-func printStatus(values map[string]string, format string, w io.Writer) (err error) {
+func IsServiceReady(ctx context.Context, container string) bool {
+	if container == utils.RestId {
+		return isPostgRESTHealthy(ctx)
+	}
+	return AssertContainerHealthy(ctx, container) == nil
+}
+
+func isPostgRESTHealthy(ctx context.Context) bool {
+	// PostgREST does not support native health checks
+	restUrl := fmt.Sprintf("http://localhost:%d/rest/v1/", utils.Config.Api.Port)
+	req, err := http.NewRequestWithContext(ctx, http.MethodHead, restUrl, nil)
+	if err != nil {
+		return false
+	}
+	req.Header.Add("apikey", utils.AnonKey)
+	resp, err := http.DefaultClient.Do(req)
+	return err == nil && resp.StatusCode == http.StatusOK
+}
+
+func printStatus(names CustomName, format string, w io.Writer, exclude ...string) (err error) {
+	values := names.toValues(exclude...)
 	switch format {
 	case OutputEnv:
 		var out string
@@ -101,9 +162,27 @@ func printStatus(values map[string]string, format string, w io.Writer) (err erro
 	case OutputToml:
 		enc := toml.NewEncoder(w)
 		err = enc.Encode(values)
-	default:
-		fmt.Fprintln(os.Stderr, utils.Aqua("supabase"), "local development setup is running.")
-		utils.ShowStatus()
 	}
 	return err
 }
+
+func PrettyPrint(w io.Writer, exclude ...string) {
+	names := CustomName{
+		ApiURL:         "         " + utils.Aqua("API URL"),
+		DbURL:          "          " + utils.Aqua("DB URL"),
+		StudioURL:      "      " + utils.Aqua("Studio URL"),
+		InbucketURL:    "    " + utils.Aqua("Inbucket URL"),
+		JWTSecret:      "      " + utils.Aqua("JWT secret"),
+		AnonKey:        "        " + utils.Aqua("anon key"),
+		ServiceRoleKey: "" + utils.Aqua("service_role key"),
+	}
+	values := names.toValues(exclude...)
+	// Iterate through map in order of declared struct fields
+	val := reflect.ValueOf(names)
+	for i := 0; i < val.NumField(); i++ {
+		k := val.Field(i).String()
+		if v, ok := values[k]; ok {
+			fmt.Fprintf(w, "%s: %s\n", k, v)
+		}
+	}
+}


Test patch:
diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go
index a58992e6..7af5f49e 100644
--- a/internal/db/reset/reset_test.go
+++ b/internal/db/reset/reset_test.go
@@ -280,9 +280,8 @@ func TestRestartDatabase(t *testing.T) {
 			Reply(http.StatusOK).
 			JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
 				State: &types.ContainerState{
-					Health: &types.Health{
-						Status: "healthy",
-					},
+					Running: true,
+					Health:  &types.Health{Status: "healthy"},
 				},
 			}})
 		utils.StorageId = "test-storage"
diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go
index 25095a88..861585ce 100644
--- a/internal/db/start/start_test.go
+++ b/internal/db/start/start_test.go
@@ -34,7 +34,10 @@ func TestInitDatabase(t *testing.T) {
 			Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json").
 			Reply(http.StatusOK).
 			JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
-				State: &types.ContainerState{Health: &types.Health{Status: "healthy"}},
+				State: &types.ContainerState{
+					Running: true,
+					Health:  &types.Health{Status: "healthy"},
+				},
 			}})
 		// Setup mock postgres
 		conn := pgtest.NewConn()
@@ -80,7 +83,10 @@ func TestInitDatabase(t *testing.T) {
 			Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json").
 			Reply(http.StatusOK).
 			JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
-				State: &types.ContainerState{Health: &types.Health{Status: "healthy"}},
+				State: &types.ContainerState{
+					Running: true,
+					Health:  &types.Health{Status: "healthy"},
+				},
 			}})
 		// Run test
 		err := initDatabase(context.Background(), fsys, io.Discard)
@@ -101,7 +107,10 @@ func TestInitDatabase(t *testing.T) {
 			Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json").
 			Reply(http.StatusOK).
 			JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
-				State: &types.ContainerState{Health: &types.Health{Status: "healthy"}},
+				State: &types.ContainerState{
+					Running: true,
+					Health:  &types.Health{Status: "healthy"},
+				},
 			}})
 		// Setup mock postgres
 		conn := pgtest.NewConn()
@@ -134,7 +143,10 @@ func TestInitDatabase(t *testing.T) {
 			Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json").
 			Reply(http.StatusOK).
 			JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
-				State: &types.ContainerState{Health: &types.Health{Status: "healthy"}},
+				State: &types.ContainerState{
+					Running: true,
+					Health:  &types.Health{Status: "healthy"},
+				},
 			}})
 		// Setup mock postgres
 		conn := pgtest.NewConn()
@@ -173,7 +185,10 @@ func TestInitDatabase(t *testing.T) {
 			Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json").
 			Reply(http.StatusOK).
 			JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
-				State: &types.ContainerState{Health: &types.Health{Status: "healthy"}},
+				State: &types.ContainerState{
+					Running: true,
+					Health:  &types.Health{Status: "healthy"},
+				},
 			}})
 		// Setup mock postgres
 		conn := pgtest.NewConn()
diff --git a/internal/start/start_test.go b/internal/start/start_test.go
index 6ab6c245..3c27a0ce 100644
--- a/internal/start/start_test.go
+++ b/internal/start/start_test.go
@@ -189,7 +189,10 @@ func TestDatabaseStart(t *testing.T) {
 				Get("/v" + utils.Docker.ClientVersion() + "/containers/" + container + "/json").
 				Reply(http.StatusOK).
 				JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
-					State: &types.ContainerState{Health: &types.Health{Status: "healthy"}},
+					State: &types.ContainerState{
+						Running: true,
+						Health:  &types.Health{Status: "healthy"},
+					},
 				}})
 		}
 		gock.New("localhost").
@@ -229,7 +232,10 @@ func TestDatabaseStart(t *testing.T) {
 			Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json").
 			Reply(http.StatusOK).
 			JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
-				State: &types.ContainerState{Health: &types.Health{Status: "healthy"}},
+				State: &types.ContainerState{
+					Running: true,
+					Health:  &types.Health{Status: "healthy"},
+				},
 			}})
 		// Setup mock postgres
 		utils.GlobalsSql = "create schema public"
diff --git a/internal/status/status_test.go b/internal/status/status_test.go
index 55491ae0..735f13ea 100644
--- a/internal/status/status_test.go
+++ b/internal/status/status_test.go
@@ -6,6 +6,7 @@ import (
 	"errors"
 	"io"
 	"net/http"
+	"strings"
 	"testing"
 
 	"github.com/docker/docker/api/types"
@@ -27,6 +28,7 @@ func TestStatusCommand(t *testing.T) {
 			"realtime-dev.supabase_realtime_",
 			"supabase_rest_",
 			"supabase_storage_",
+			"storage_imgproxy_",
 			"supabase_pg_meta_",
 			"supabase_studio_",
 		}
@@ -36,11 +38,6 @@ func TestStatusCommand(t *testing.T) {
 		// Setup mock docker
 		require.NoError(t, apitest.MockDocker(utils.Docker))
 		defer gock.OffAll()
-		gock.New(utils.Docker.DaemonHost()).
-			Head("/_ping").
-			Reply(http.StatusOK).
-			SetHeader("API-Version", utils.Docker.ClientVersion()).
-			SetHeader("OSType", "linux")
 		for _, container := range services {
 			gock.New(utils.Docker.DaemonHost()).
 				Get("/v" + utils.Docker.ClientVersion() + "/containers/" + container).
@@ -78,10 +75,7 @@ func TestStatusCommand(t *testing.T) {
 		require.NoError(t, apitest.MockDocker(utils.Docker))
 		defer gock.OffAll()
 		gock.New(utils.Docker.DaemonHost()).
-			Head("/_ping").
-			Reply(http.StatusServiceUnavailable)
-		gock.New(utils.Docker.DaemonHost()).
-			Get("/_ping").
+			Get("/v" + utils.Docker.ClientVersion() + "/containers/supabase_db_").
 			ReplyError(errors.New("network error"))
 		// Run test
 		err := Run(context.Background(), CustomName{}, OutputPretty, fsys)
@@ -89,28 +83,6 @@ func TestStatusCommand(t *testing.T) {
 		assert.ErrorContains(t, err, "network error")
 		assert.Empty(t, apitest.ListUnmatchedRequests())
 	})
-
-	t.Run("throws error on missing container", func(t *testing.T) {
-		// Setup in-memory fs
-		fsys := afero.NewMemMapFs()
-		require.NoError(t, utils.WriteConfig(fsys, false))
-		// Setup mock docker
-		require.NoError(t, apitest.MockDocker(utils.Docker))
-		defer gock.OffAll()
-		gock.New(utils.Docker.DaemonHost()).
-			Head("/_ping").
-			Reply(http.StatusOK).
-			SetHeader("API-Version", utils.Docker.ClientVersion()).
-			SetHeader("OSType", "linux")
-		gock.New(utils.Docker.DaemonHost()).
-			Get("/v" + utils.Docker.ClientVersion() + "/containers").
-			Reply(http.StatusNotFound)
-		// Run test
-		err := Run(context.Background(), CustomName{}, OutputPretty, fsys)
-		// Check error
-		assert.ErrorContains(t, err, "container not found. Have you run supabase start?")
-		assert.Empty(t, apitest.ListUnmatchedRequests())
-	})
 }
 
 func TestServiceHealth(t *testing.T) {
@@ -124,7 +96,10 @@ func TestServiceHealth(t *testing.T) {
 			Get("/v" + utils.Docker.ClientVersion() + "/containers/" + services[0] + "/json").
 			Reply(http.StatusOK).
 			JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
-				State: &types.ContainerState{Running: true},
+				State: &types.ContainerState{
+					Running: true,
+					Health:  &types.Health{Status: "Unhealthy"},
+				},
 			}})
 		gock.New(utils.Docker.DaemonHost()).
 			Get("/v" + utils.Docker.ClientVersion() + "/containers/" + services[1] + "/json").
@@ -134,9 +109,14 @@ func TestServiceHealth(t *testing.T) {
 			}})
 		// Run test
 		var stderr bytes.Buffer
-		assert.NoError(t, checkServiceHealth(context.Background(), services, &stderr))
+		stopped := checkServiceHealth(context.Background(), services, &stderr)
 		// Check error
-		assert.Equal(t, "supabase_auth container is not running: exited\n", stderr.String())
+		assert.Empty(t, stopped)
+		lines := strings.Split(strings.TrimSpace(stderr.String()), "\n")
+		assert.ElementsMatch(t, []string{
+			"supabase_db container is not ready: Unhealthy",
+			"supabase_auth container is not running: exited",
+		}, lines)
 		assert.Empty(t, apitest.ListUnmatchedRequests())
 	})
 
@@ -147,47 +127,57 @@ func TestServiceHealth(t *testing.T) {
 		// Setup mock docker
 		require.NoError(t, apitest.MockDocker(utils.Docker))
 		defer gock.OffAll()
-		gock.New(utils.Docker.DaemonHost()).
-			Get("/v" + utils.Docker.ClientVersion() + "/containers/" + services[0] + "/json").
-			Reply(http.StatusNotFound)
+		for _, name := range services {
+			gock.New(utils.Docker.DaemonHost()).
+				Get("/v" + utils.Docker.ClientVersion() + "/containers/" + name + "/json").
+				Reply(http.StatusNotFound)
+		}
 		// Run test
-		err := checkServiceHealth(context.Background(), services, io.Discard)
+		stopped := checkServiceHealth(context.Background(), services, io.Discard)
 		// Check error
-		assert.ErrorContains(t, err, "supabase_db container not found. Have you run supabase start?")
+		assert.ElementsMatch(t, services, stopped)
 		assert.Empty(t, apitest.ListUnmatchedRequests())
 	})
 }
 
 func TestPrintStatus(t *testing.T) {
+	utils.Config.Db.Port = 0
+	exclude := []string{
+		utils.ShortContainerImageName(utils.PostgrestImage),
+		utils.ShortContainerImageName(utils.StudioImage),
+		utils.GotrueId,
+		utils.InbucketId,
+	}
+
 	t.Run("outputs env var", func(t *testing.T) {
 		// Run test
 		var stdout bytes.Buffer
-		assert.NoError(t, printStatus(map[string]string{"2": "b", "1": "a"}, OutputEnv, &stdout))
+		assert.NoError(t, printStatus(CustomName{DbURL: "DB_URL"}, OutputEnv, &stdout, exclude...))
 		// Check error
-		assert.Equal(t, "1=\"a\"\n2=\"b\"\n", stdout.String())
+		assert.Equal(t, "DB_URL=\"postgresql://postgres:postgres@localhost:0/postgres\"\n", stdout.String())
 	})
 
 	t.Run("outputs json object", func(t *testing.T) {
 		// Run test
 		var stdout bytes.Buffer
-		assert.NoError(t, printStatus(map[string]string{"2": "b", "1": "a"}, OutputJson, &stdout))
+		assert.NoError(t, printStatus(CustomName{DbURL: "DB_URL"}, OutputJson, &stdout, exclude...))
 		// Check error
-		assert.Equal(t, "{\"1\":\"a\",\"2\":\"b\"}\n", stdout.String())
+		assert.Equal(t, "{\"DB_URL\":\"postgresql://postgres:postgres@localhost:0/postgres\"}\n", stdout.String())
 	})
 
 	t.Run("outputs yaml properties", func(t *testing.T) {
 		// Run test
 		var stdout bytes.Buffer
-		assert.NoError(t, printStatus(map[string]string{"2": "b", "1": "a"}, OutputYaml, &stdout))
+		assert.NoError(t, printStatus(CustomName{DbURL: "DB_URL"}, OutputYaml, &stdout, exclude...))
 		// Check error
-		assert.Equal(t, "\"1\": a\n\"2\": b\n", stdout.String())
+		assert.Equal(t, "DB_URL: postgresql://postgres:postgres@localhost:0/postgres\n", stdout.String())
 	})
 
 	t.Run("outputs toml fields", func(t *testing.T) {
 		// Run test
 		var stdout bytes.Buffer
-		assert.NoError(t, printStatus(map[string]string{"2": "b", "1": "a"}, OutputToml, &stdout))
+		assert.NoError(t, printStatus(CustomName{DbURL: "DB_URL"}, OutputToml, &stdout, exclude...))
 		// Check error
-		assert.Equal(t, "1 = \"a\"\n2 = \"b\"\n", stdout.String())
+		assert.Equal(t, "DB_URL = \"postgresql://postgres:postgres@localhost:0/postgres\"\n", stdout.String())
 	})
 }