Command -generate should work on non-existent dir

This commit is contained in:
Jakob Borg
2014-12-12 21:39:03 +01:00
parent 0cc815d816
commit b2ed32b118
2 changed files with 33 additions and 4 deletions

View File

@@ -54,3 +54,29 @@ func TestCLIReset(t *testing.T) {
}
}
}
func TestCLIGenerate(t *testing.T) {
err := os.RemoveAll("home.out")
if err != nil {
t.Fatal(err)
}
// -generate should create a bunch of stuff
cmd := exec.Command("../bin/syncthing", "-generate", "home.out")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stdout
err = cmd.Run()
if err != nil {
t.Fatal(err)
}
// Verify that the files that should have been created have been
for _, f := range []string{"home.out/config.xml", "home.out/cert.pem", "home.out/key.pem"} {
_, err := os.Stat(f)
if err != nil {
t.Errorf("%s is not correctly generated", f)
}
}
}