From 02a9d1fa3494fceef0454e292672091f81ffc461 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Wed, 5 Jul 2017 01:09:21 +0200 Subject: [PATCH] Add some integration tests --- .gitignore | 1 + tests/RunAll.cmd | 5 +++ tests/test_DeleteAndRestitution.cmd | 51 ++++++++++++++++++++++++ tests/test_MoveToSubdir.cmd | 49 +++++++++++++++++++++++ tests/test_MoveToSubdirAndRestore.cmd | 57 +++++++++++++++++++++++++++ tests/test_UpdateFile.cmd | 49 +++++++++++++++++++++++ 6 files changed, 212 insertions(+) create mode 100644 tests/RunAll.cmd create mode 100644 tests/test_DeleteAndRestitution.cmd create mode 100644 tests/test_MoveToSubdir.cmd create mode 100644 tests/test_MoveToSubdirAndRestore.cmd create mode 100644 tests/test_UpdateFile.cmd diff --git a/.gitignore b/.gitignore index b19ec65..a4320ff 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ VisualStudio/filesync/x64/* *.ilk *.VC.db *.VC.opendb +tests/tmp/* diff --git a/tests/RunAll.cmd b/tests/RunAll.cmd new file mode 100644 index 0000000..56f88ff --- /dev/null +++ b/tests/RunAll.cmd @@ -0,0 +1,5 @@ +@echo off + +for /r %%v in (test_*.cmd) do call "%%v" + +pause diff --git a/tests/test_DeleteAndRestitution.cmd b/tests/test_DeleteAndRestitution.cmd new file mode 100644 index 0000000..83e3e24 --- /dev/null +++ b/tests/test_DeleteAndRestitution.cmd @@ -0,0 +1,51 @@ + +:: Prepare test +set testName=%~n0 +set testDir=tmp\%testName% +IF EXIST %testDir%.A rmdir %testDir%.A /S /Q +IF EXIST %testDir%.B rmdir %testDir%.B /S /Q +IF EXIST %testDir%.txt del %testDir%.txt + +echo:Start> %testDir%.txt +IF NOT EXIST tmp md tmp +md %testDir%.A +md %testDir%.B + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +echo:Uno> %testDir%.A\Uno.txt +echo:Dos> %testDir%.A\Dos.txt +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +del %testDir%.A\Uno.txt +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +ping 127.0.0.1 -n 6 > nul + +echo:UnoRepuesto> %testDir%.A\Uno.txt +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +..\filesync.exe read %testDir%.A/nodesFile.fs >> %testDir%.txt +..\filesync.exe read %testDir%.B/nodesFile.fs >> %testDir%.txt + +:: Check test results + +IF NOT EXIST %testDir%.A\Uno.txt goto error +IF NOT EXIST %testDir%.A\Dos.txt goto error + +IF NOT EXIST %testDir%.B\Uno.txt goto error +IF NOT EXIST %testDir%.B\Dos.txt goto error + + +:: Display test result +goto end +:error +echo:Test %testName% Failed...>> %testDir%.txt +echo:Test %testName% Failed... +goto eof +:end +echo:Test %testName% OK!>> %testDir%.txt +echo:Test %testName% OK! +:eof diff --git a/tests/test_MoveToSubdir.cmd b/tests/test_MoveToSubdir.cmd new file mode 100644 index 0000000..74b9d0c --- /dev/null +++ b/tests/test_MoveToSubdir.cmd @@ -0,0 +1,49 @@ + +:: Prepare test +set testName=%~n0 +set testDir=tmp\%testName% +IF EXIST %testDir%.A rmdir %testDir%.A /S /Q +IF EXIST %testDir%.B rmdir %testDir%.B /S /Q +IF EXIST %testDir%.txt del %testDir%.txt + +echo:Start> %testDir%.txt +IF NOT EXIST tmp md tmp +md %testDir%.A +md %testDir%.B + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +echo:Uno> %testDir%.A\Uno.txt +echo:Dos> %testDir%.A\Dos.txt +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +md %testDir%.A\dirUno +move %testDir%.A\Uno.txt %testDir%.A\dirUno\Uno.txt >NUL +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +..\filesync.exe read %testDir%.A/nodesFile.fs >> %testDir%.txt +..\filesync.exe read %testDir%.B/nodesFile.fs >> %testDir%.txt + +:: Check test results + +IF EXIST %testDir%.A\Uno.txt goto error +IF NOT EXIST %testDir%.A\dirUno\Uno.txt goto error +IF NOT EXIST %testDir%.A\Dos.txt goto error + +IF EXIST %testDir%.B\Uno.txt goto error +IF NOT EXIST %testDir%.B\dirUno\Uno.txt goto error +IF NOT EXIST %testDir%.B\Dos.txt goto error + + +:: Display test result +goto end +:error +echo:Test %testName% Failed...>> %testDir%.txt +echo:Test %testName% Failed... +goto eof +:end +echo:Test %testName% OK!>> %testDir%.txt +echo:Test %testName% OK! +:eof diff --git a/tests/test_MoveToSubdirAndRestore.cmd b/tests/test_MoveToSubdirAndRestore.cmd new file mode 100644 index 0000000..441cf89 --- /dev/null +++ b/tests/test_MoveToSubdirAndRestore.cmd @@ -0,0 +1,57 @@ + +:: Prepare test +set testName=%~n0 +set testDir=tmp\%testName% +IF EXIST %testDir%.A rmdir %testDir%.A /S /Q +IF EXIST %testDir%.B rmdir %testDir%.B /S /Q +IF EXIST %testDir%.txt del %testDir%.txt + +echo:Start> %testDir%.txt +IF NOT EXIST tmp md tmp +md %testDir%.A +md %testDir%.B + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +echo:Uno> %testDir%.A\Uno.txt +echo:Dos> %testDir%.A\Dos.txt +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +md %testDir%.A\dirUno +move %testDir%.A\Uno.txt %testDir%.A\dirUno\Uno.txt >NUL +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +ping 127.0.0.1 -n 6 > nul + +move %testDir%.A\dirUno\Uno.txt %testDir%.A\Uno.txt >NUL +rd %testDir%.A\dirUno +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +..\filesync.exe read %testDir%.A/nodesFile.fs >> %testDir%.txt +..\filesync.exe read %testDir%.B/nodesFile.fs >> %testDir%.txt + +:: Check test results + +IF NOT EXIST %testDir%.A\Uno.txt goto error +IF EXIST %testDir%.A\dirUno goto error +IF EXIST %testDir%.A\dirUno\Uno.txt goto error +IF NOT EXIST %testDir%.A\Dos.txt goto error + +IF NOT EXIST %testDir%.B\Uno.txt goto error +IF EXIST %testDir%.B\dirUno goto error +IF EXIST %testDir%.B\dirUno\Uno.txt goto error +IF NOT EXIST %testDir%.B\Dos.txt goto error + + +:: Display test result +goto end +:error +echo:Test %testName% Failed...>> %testDir%.txt +echo:Test %testName% Failed... +goto eof +:end +echo:Test %testName% OK!>> %testDir%.txt +echo:Test %testName% OK! +:eof diff --git a/tests/test_UpdateFile.cmd b/tests/test_UpdateFile.cmd new file mode 100644 index 0000000..fe2b436 --- /dev/null +++ b/tests/test_UpdateFile.cmd @@ -0,0 +1,49 @@ + +:: Prepare test +set testName=%~n0 +set testDir=tmp\%testName% +IF EXIST %testDir%.A rmdir %testDir%.A /S /Q +IF EXIST %testDir%.B rmdir %testDir%.B /S /Q +IF EXIST %testDir%.txt del %testDir%.txt + +echo:Start> %testDir%.txt +IF NOT EXIST tmp md tmp +md %testDir%.A +md %testDir%.B + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +echo:Uno> %testDir%.A\Uno.txt +echo:Dos> %testDir%.A\Dos.txt +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +ping 127.0.0.1 -n 6 > nul + +echo:Updated>> %testDir%.A\Uno.txt +..\filesync.exe sync %testDir%.A %testDir%.B >> %testDir%.txt + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +..\filesync.exe read %testDir%.A/nodesFile.fs >> %testDir%.txt +..\filesync.exe read %testDir%.B/nodesFile.fs >> %testDir%.txt + +:: Check test results + +IF NOT EXIST %testDir%.A\Uno.txt goto error +IF NOT EXIST %testDir%.A\Dos.txt goto error + +IF NOT EXIST %testDir%.B\Uno.txt goto error +IF NOT EXIST %testDir%.B\Dos.txt goto error + +FC %testDir%.A\Uno.txt %testDir%.B\Uno.txt >NUL || goto error + +:: Display test result +goto end +:error +echo:Test %testName% Failed...>> %testDir%.txt +echo:Test %testName% Failed... +goto eof +:end +echo:Test %testName% OK!>> %testDir%.txt +echo:Test %testName% OK! +:eof