-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move CLI utilities into internal/util/cli from internal/util to balan…
…ce tests (#5386) * Move CLI utilities into internal/util/cli from internal/util to balance tests * Fix lint complaint * Remove remote server connection from tests -- sometimes, the connection dial seems to stall
- Loading branch information
1 parent
fc18f0f
commit 07e670c
Showing
12 changed files
with
774 additions
and
773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// SPDX-FileCopyrightText: Copyright 2025 The Minder Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package cli_test | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/mindersec/minder/internal/util/cli" | ||
) | ||
|
||
// TestGetConfigDirPath tests the GetConfigDirPath function | ||
func TestGetConfigDirPath(t *testing.T) { | ||
t.Parallel() | ||
tests := []struct { | ||
name string | ||
envVar string | ||
expectedPath string | ||
expectingError bool | ||
}{ | ||
{ | ||
name: "XDG_CONFIG_HOME set", | ||
envVar: "/custom/config", | ||
expectedPath: "/custom/config/minder", | ||
expectingError: false, | ||
}, | ||
{ | ||
name: "XDG_CONFIG_HOME is not set", | ||
envVar: "", | ||
expectedPath: filepath.Join(os.Getenv("HOME"), ".config", "minder"), | ||
expectingError: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
setEnvVar(t, XdgConfigHomeEnvVar, tt.envVar) | ||
path, err := cli.GetConfigDirPath() | ||
if (err != nil) != tt.expectingError { | ||
t.Errorf("expected error: %v, got: %v", tt.expectingError, err) | ||
} | ||
if path != tt.expectedPath { | ||
t.Errorf("expected path: %s, got: %s", tt.expectedPath, path) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.