Skip to content

Commit

Permalink
Make cfgvars unit test pass on windows
Browse files Browse the repository at this point in the history
Signed-off-by: Natanael Copa <ncopa@mirantis.com>
  • Loading branch information
ncopa committed Jan 6, 2025
1 parent e3ab3c1 commit 8c30737
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/config/cfgvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ func WithCommand(cmd command) CfgVarOption {
}

if f, err := flags.GetString("kubelet-root-dir"); err == nil && f != "" {
c.KubeletRootDir = f
if f, err := filepath.Abs(f); err == nil {
c.KubeletRootDir = f
}
}

if f, err := flags.GetString("config"); err == nil && f != "" {
Expand Down
5 changes: 4 additions & 1 deletion pkg/config/cfgvars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ func TestWithCommand(t *testing.T) {
c := &CfgVars{}
WithCommand(fakeCmd)(c)

dir, err := filepath.Abs("/path/to/kubelet")
assert.NoError(t, err)

assert.Same(t, in, c.stdin)
assert.Equal(t, "/path/to/data", c.DataDir)
assert.Equal(t, "/path/to/kubelet", c.KubeletRootDir)
assert.Equal(t, dir, c.KubeletRootDir)
assert.Equal(t, "/path/to/config", c.StartupConfigPath)
assert.Equal(t, "/path/to/socket", c.StatusSocketPath)
assert.True(t, c.EnableDynamicConfig)
Expand Down

0 comments on commit 8c30737

Please sign in to comment.