Skip to content

Commit

Permalink
test: integration test for skip-unreachable-dirs flag
Browse files Browse the repository at this point in the history
  • Loading branch information
renzodavid9 committed Nov 6, 2023
1 parent 325ae6c commit 27beaa1
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package integration

import (
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -211,3 +212,47 @@ func exitCode(err error) int {

return 1
}

func TestInitWithDirWithoutReadPerms(t *testing.T) {
MarkIntegrationTest(t, CanRunWithoutGcp)
tests := []struct {
description string
shouldFail bool
flags []string
dir string
dirToCreate string
}{
{
description: "without --skip-unreachable-dirs flag, should fail",
shouldFail: true,
flags: []string{"--analyze"},
dir: "testdata/getting-started/",
dirToCreate: "dir1",
},
{
description: "with --skip-unreachable-dirs flag, shouldn't fail",
shouldFail: false,
flags: []string{"--analyze", "--skip-unreachable-dirs"},
dir: "testdata/getting-started",
dirToCreate: "dir2",
},
}

for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
tmpDir := testutil.NewTempDir(t.T)
copyFiles(tmpDir.Root(), test.dir)

dirWithoutReadPerms := filepath.Join(tmpDir.Root(), test.dirToCreate)
os.MkdirAll(dirWithoutReadPerms, 0377)
defer os.Remove(dirWithoutReadPerms)

output, err := skaffold.Init(test.flags...).InDir(tmpDir.Root()).RunWithCombinedOutput(t.T)
t.CheckError(test.shouldFail, err)
if test.shouldFail {
t.CheckDeepEqual(fmt.Sprintf("open %v: permission denied\n", test.dirToCreate), string(output))
}
})
}

}

0 comments on commit 27beaa1

Please sign in to comment.