Skip to content

Commit

Permalink
Replace weird test in rmOldCamera for a "normal" one
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel-Dorta committed Sep 8, 2019
1 parent edba51d commit 457a9e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 6 additions & 2 deletions cmd/rmOldCamera/rmOldCamera.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ func parseDaysToPreserve(dtp string) {
earliestTimeToPreserve = time.Now().AddDate(0, 0, daysToPreserve * -1)
}

func main() {
func getArgs() string {
internal.CheckSpecialArgs(os.Args, USAGE)
if len(os.Args) != 3 {
fmt.Printf("Usage: %s %s (use -h for help)\n", os.Args[0], USAGE)
os.Exit(1)
}

path := os.Args[1]
parseDaysToPreserve(os.Args[2])
return os.Args[1]
}

func main() {
path := getArgs()

errs := iterateCams(path)
if len(errs) != 0 {
Expand Down
11 changes: 9 additions & 2 deletions cmd/rmOldCamera/rmOldCamera_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ func Test(t *testing.T) {
// Not deleted for manual inspection

createTestFiles(tmpDirPath, t)
os.Args = []string{"./rmOldCamera_test", tmpDirPath, "30"}
main()
parseDaysToPreserve("30")
errs := iterateCams(tmpDirPath)

if len(errs) != 0 {
for _, err := range errs {
t.Error(err)
}
t.FailNow()
}
}

func createTestFiles(path string, t *testing.T) {
Expand Down

0 comments on commit 457a9e9

Please sign in to comment.