From 79ff64f06d67231e067e1f3e48bec9970be54eb5 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 26 Jun 2023 13:35:42 +0200 Subject: [PATCH] cli/command/context: don't use pkg/homedir in test I'm considering deprecating the "Key()" utility, as it was only used in tests. Signed-off-by: Sebastiaan van Stijn --- cli/command/context/use_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/command/context/use_test.go b/cli/command/context/use_test.go index d7521abcdb..0d95ee2cb3 100644 --- a/cli/command/context/use_test.go +++ b/cli/command/context/use_test.go @@ -6,6 +6,7 @@ import ( "io" "os" "path/filepath" + "runtime" "testing" "github.com/docker/cli/cli/command" @@ -13,7 +14,6 @@ import ( "github.com/docker/cli/cli/config/configfile" "github.com/docker/cli/cli/flags" "github.com/docker/docker/errdefs" - "github.com/docker/docker/pkg/homedir" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -57,7 +57,11 @@ func TestUseDefaultWithoutConfigFile(t *testing.T) { // the _default_ configuration file. If we specify a custom configuration // file, the CLI produces an error if the file doesn't exist. tmpHomeDir := t.TempDir() - t.Setenv(homedir.Key(), tmpHomeDir) + if runtime.GOOS == "windows" { + t.Setenv("USERPROFILE", tmpHomeDir) + } else { + t.Setenv("HOME", tmpHomeDir) + } configDir := filepath.Join(tmpHomeDir, ".docker") configFilePath := filepath.Join(configDir, "config.json")