cli_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This program is free software: you can redistribute it and/or modify it
  4. // under the terms of the GNU General Public License as published by the Free
  5. // Software Foundation, either version 3 of the License, or (at your option)
  6. // any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful, but WITHOUT
  9. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. // more details.
  12. //
  13. // You should have received a copy of the GNU General Public License along
  14. // with this program. If not, see <http://www.gnu.org/licenses/>.
  15. // +build integration
  16. package integration_test
  17. import (
  18. "os"
  19. "os/exec"
  20. "testing"
  21. )
  22. func TestCLIReset(t *testing.T) {
  23. dirs := []string{"s1", "s12-1", "h1/index"}
  24. // Create directories that reset will remove
  25. for _, dir := range dirs {
  26. err := os.Mkdir(dir, 0755)
  27. if err != nil && !os.IsExist(err) {
  28. t.Fatal(err)
  29. }
  30. }
  31. // Run reset to clean up
  32. cmd := exec.Command("../bin/syncthing", "-home", "h1", "-reset")
  33. cmd.Stdout = os.Stdout
  34. cmd.Stderr = os.Stdout
  35. err := cmd.Run()
  36. if err != nil {
  37. t.Fatal(err)
  38. }
  39. // Verify that they're gone
  40. for _, dir := range dirs {
  41. _, err := os.Stat(dir)
  42. if err == nil {
  43. t.Errorf("%s still exists", dir)
  44. }
  45. }
  46. }