TestLoadDanglingSymlink verifies that we gracefully handle dangling symlinks. TODO(thaJeztah): consider whether we want dangling symlinks to be an error condition instead.
(t *testing.T)
| 54 | // |
| 55 | // TODO(thaJeztah): consider whether we want dangling symlinks to be an error condition instead. |
| 56 | func TestLoadDanglingSymlink(t *testing.T) { |
| 57 | cfgDir := t.TempDir() |
| 58 | cfgFile := filepath.Join(cfgDir, ConfigFileName) |
| 59 | err := os.Symlink(filepath.Join(cfgDir, "no-such-file"), cfgFile) |
| 60 | assert.NilError(t, err) |
| 61 | |
| 62 | config, err := Load(cfgDir) |
| 63 | assert.NilError(t, err) |
| 64 | |
| 65 | // Now save it and make sure it shows up in new form |
| 66 | saveConfigAndValidateNewFormat(t, config, cfgDir) |
| 67 | |
| 68 | // Make sure we kept the symlink. |
| 69 | fi, err := os.Lstat(cfgFile) |
| 70 | assert.NilError(t, err) |
| 71 | assert.Equal(t, fi.Mode()&os.ModeSymlink, os.ModeSymlink, "expected %v to be a symlink", cfgFile) |
| 72 | } |
| 73 | |
| 74 | func TestLoadNoPermissions(t *testing.T) { |
| 75 | if runtime.GOOS != "windows" { |
nothing calls this directly
no test coverage detected
searching dependent graphs…