Update TestCacheInit to dir instead of file

Windows doesn't seem to support `+x` for files, ending up with
permissions looking like `-rw-rw-rw-` which is not `0777`, which leads
in the test to fail.

The main idea of the `cache-init` is to change permissions for
directories not files so we should update the test to reflect that.
parent 56efef02
Pipeline #50430537 passed with stages
in 72 minutes and 32 seconds
......@@ -26,27 +26,27 @@ func newCacheInitTestApp() *cli.App {
func TestCacheInit(t *testing.T) {
// Specifically test a file name with spaces.
file, err := ioutil.TempFile("", "Test Cache Chmod")
// Specifically test a dir name with spaces.
dir, err := ioutil.TempDir("", "Test Cache Chmod")
require.NoError(t, err)
defer os.Remove(file.Name())
defer os.Remove(dir)
// Make sure that the mode is not the expect 0777.
err = os.Chmod(file.Name(), 0600)
err = os.Chmod(dir, 0600)
require.NoError(t, err)
// Start a new cli with the arguments for the command.
args := os.Args[0:1]
args = append(args, "cache-init", file.Name())
args = append(args, "cache-init", dir)
err = newCacheInitTestApp().Run(args)
require.NoError(t, err)
info, err := os.Stat(file.Name())
info, err := os.Stat(dir)
require.NoError(t, err)
assert.Equal(t, os.ModePerm, info.Mode())
assert.Equal(t, os.ModeDir+os.ModePerm, info.Mode())
func TestCacheInit_NoArguments(t *testing.T) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment