Skip to content

Commit 33f949d

Browse files
committed
lakebox: skip Unix perm assertions in state test on Windows
Go on Windows synthesizes file mode from the read-only attribute (0o666/0o777), so the 0o600/0o700 assertions can never hold. Matches the existing pattern used in libs/cache, libs/completion, and the ssh vscode settings tests. Co-authored-by: Isaac
1 parent 29b16f9 commit 33f949d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

cmd/lakebox/state_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/fs"
66
"os"
77
"path/filepath"
8+
"runtime"
89
"testing"
910

1011
"github.com/databricks/cli/libs/env"
@@ -146,11 +147,16 @@ func TestStateSaveCreatesParentDirs(t *testing.T) {
146147
// File and parent dir now exist with sensible perms.
147148
info, err := os.Stat(path)
148149
require.NoError(t, err)
149-
assert.Equal(t, os.FileMode(0o600), info.Mode().Perm())
150150

151151
dirInfo, err := os.Stat(filepath.Dir(path))
152152
require.NoError(t, err)
153-
assert.Equal(t, os.FileMode(0o700), dirInfo.Mode().Perm())
153+
154+
// Windows does not honor Unix permission bits; os.Stat reports 0o666/0o777
155+
// regardless of what was passed to OpenFile/MkdirAll.
156+
if runtime.GOOS != "windows" {
157+
assert.Equal(t, os.FileMode(0o600), info.Mode().Perm())
158+
assert.Equal(t, os.FileMode(0o700), dirInfo.Mode().Perm())
159+
}
154160
}
155161

156162
// Defaults of nil on disk (legal but not what saveState produces) must still

0 commit comments

Comments
 (0)