Skip to content

Commit

Permalink
skip file permission test on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinapathak committed Aug 21, 2024
1 parent 56ec03b commit 0954dd4
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,13 @@ func TestSkipGenerate(t *testing.T) {

func TestGenerateAndCompile(t *testing.T) {
replaces := generateReplaces()
testCases := []struct {
testCase string
cfgBuilder func(t *testing.T) Config
verifyFiles func(t *testing.T, dir string)
expectedErr string
}{
type testDesc struct{
testCase string
cfgBuilder func(t *testing.T) Config
verifyFiles func(t *testing.T, dir string)
expectedErr string
}
testCases := []testDesc{
{
testCase: "Default Configuration Compilation",
cfgBuilder: func(t *testing.T) Config {
Expand Down Expand Up @@ -384,19 +385,6 @@ func TestGenerateAndCompile(t *testing.T) {
return cfg
},
},
{
testCase: "No Dir Permissions",
cfgBuilder: func(t *testing.T) Config {
cfg := newTestConfig()
err := cfg.SetBackwardsCompatibility()
require.NoError(t, err)
cfg.Distribution.OutputPath = t.TempDir()
assert.NoError(t, os.Chmod(cfg.Distribution.OutputPath, 0400))
cfg.Replaces = append(cfg.Replaces, replaces...)
return cfg
},
expectedErr: "failed to generate source file",
},
{
testCase: "Invalid Output Path",
cfgBuilder: func(t *testing.T) Config {
Expand Down Expand Up @@ -429,6 +417,23 @@ func TestGenerateAndCompile(t *testing.T) {
},
}

// file permissions don't work the same on windows systems, so this test always passes.
if runtime.GOOS != "windows" {
testCases = append(testCases, testDesc{
testCase: "No Dir Permissions",
cfgBuilder: func(t *testing.T) Config {
cfg := newTestConfig()
err := cfg.SetBackwardsCompatibility()
require.NoError(t, err)
cfg.Distribution.OutputPath = t.TempDir()
assert.NoError(t, os.Chmod(cfg.Distribution.OutputPath, 0400))
cfg.Replaces = append(cfg.Replaces, replaces...)
return cfg
},
expectedErr: "failed to generate source file",
})
}

for _, tt := range testCases {
t.Run(tt.testCase, func(t *testing.T) {
cfg := tt.cfgBuilder(t)
Expand Down

0 comments on commit 0954dd4

Please sign in to comment.