Skip to content

Commit

Permalink
Add test to generic_rmOldCameraData
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel-Dorta committed Nov 27, 2019
1 parent d14bfc8 commit 6969b61
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 54 deletions.
1 change: 0 additions & 1 deletion cmd/generic_rmOldCameraData/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func init() {
oldestPreserve = time.Now().AddDate(0, 0, days * -1)
}

// TODO rewrite tests
func main() {
if err := utils.IterateDir(path, func(f os.FileInfo) {
if !f.IsDir() {
Expand Down
53 changes: 0 additions & 53 deletions cmd/generic_rmOldCameraData/main_test.go

This file was deleted.

36 changes: 36 additions & 0 deletions test/generic_rmOldCameraData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

TMP_DIR="/tmp/generic_rmOldCameraData"
DATA_DIR="${TMP_DIR}/data"
BUILD_PATH="${TMP_DIR}/build/generic_rmOldCameraData"

# Clean previous test
rm -Rf "$TMP_DIR"

# Build executable
go build -o "$BUILD_PATH" "${GOPATH}/src/github.com/Miguel-Dorta/surveillance-cameras/cmd/generic_rmOldCameraData"

# Create testdata
for (( c = 0; c <= 5; c++ )); do
cPath="${DATA_DIR}/C$(printf %03d $c)"

for (( y = 1950; y <= 2100; y++ )); do
yPath="${cPath}/${y}"

for (( m = 1; m <= 12; m++ )); do
mPath="${yPath}/$(printf %02d $m)"

for (( d = 1; d < 31; d++ )); do
dPath="${mPath}/$(printf %02d $d)"
mkdir -p "$dPath"
touch "${dPath}/testfile"
done
done
done
done

# Execute it
$BUILD_PATH -path "$DATA_DIR" -days 0

# Output
echo "Please, check $DATA_DIR"

0 comments on commit 6969b61

Please sign in to comment.