Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
daef29e432 |
@@ -553,6 +553,31 @@ func TestStartupFailsWhenDataDirNotWritable(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestStartupFailsWhenExistingDataDirNotWritable verifies that startup
|
||||||
|
// stops when the data directory exists but the temp file that saving uses
|
||||||
|
// cannot be written in it. A directory sitting at the temp file's path
|
||||||
|
// makes that write fail, which also holds as root.
|
||||||
|
func TestStartupFailsWhenExistingDataDirNotWritable(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
dataDir := t.TempDir()
|
||||||
|
|
||||||
|
err := os.Mkdir(filepath.Join(dataDir, "state.json.tmp"), 0o700)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("creating directory: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = startState(t, dataDir)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("startup should fail when the data directory is not writable")
|
||||||
|
}
|
||||||
|
|
||||||
|
want := "data directory " + dataDir + " is not writable"
|
||||||
|
if !strings.Contains(err.Error(), want) {
|
||||||
|
t.Errorf("startup error %q does not contain %q", err, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestStartupCreatesDataDir verifies that startup creates a missing
|
// TestStartupCreatesDataDir verifies that startup creates a missing
|
||||||
// data directory and leaves nothing behind in it.
|
// data directory and leaves nothing behind in it.
|
||||||
func TestStartupCreatesDataDir(t *testing.T) {
|
func TestStartupCreatesDataDir(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user