forked from TrueCloudLab/restic
restic-from-command: add tests
This commit is contained in:
parent
81f8d473df
commit
c0ca54dc8a
1 changed files with 52 additions and 0 deletions
|
@ -568,3 +568,55 @@ func linkEqual(source, dest []string) bool {
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStdinFromCommand(t *testing.T) {
|
||||||
|
env, cleanup := withTestEnvironment(t)
|
||||||
|
defer cleanup()
|
||||||
|
|
||||||
|
testSetupBackupData(t, env)
|
||||||
|
opts := BackupOptions{
|
||||||
|
StdinCommand: true,
|
||||||
|
StdinFilename: "stdin",
|
||||||
|
}
|
||||||
|
|
||||||
|
testRunBackup(t, filepath.Dir(env.testdata), []string{"ls"}, opts, env.gopts)
|
||||||
|
testListSnapshots(t, env.gopts, 1)
|
||||||
|
|
||||||
|
testRunCheck(t, env.gopts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStdinFromCommandFailNoOutput(t *testing.T) {
|
||||||
|
env, cleanup := withTestEnvironment(t)
|
||||||
|
defer cleanup()
|
||||||
|
|
||||||
|
testSetupBackupData(t, env)
|
||||||
|
opts := BackupOptions{
|
||||||
|
StdinCommand: true,
|
||||||
|
StdinFilename: "stdin",
|
||||||
|
}
|
||||||
|
|
||||||
|
err := testRunBackupAssumeFailure(t, filepath.Dir(env.testdata), []string{"python", "-c", "import sys; sys.exit(1)"}, opts, env.gopts)
|
||||||
|
rtest.Assert(t, err != nil, "Expected error while backing up")
|
||||||
|
|
||||||
|
testListSnapshots(t, env.gopts, 0)
|
||||||
|
|
||||||
|
testRunCheck(t, env.gopts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStdinFromCommandFailExitCode(t *testing.T) {
|
||||||
|
env, cleanup := withTestEnvironment(t)
|
||||||
|
defer cleanup()
|
||||||
|
|
||||||
|
testSetupBackupData(t, env)
|
||||||
|
opts := BackupOptions{
|
||||||
|
StdinCommand: true,
|
||||||
|
StdinFilename: "stdin",
|
||||||
|
}
|
||||||
|
|
||||||
|
err := testRunBackupAssumeFailure(t, filepath.Dir(env.testdata), []string{"python", "-c", "import sys; print('test'); sys.exit(1)"}, opts, env.gopts)
|
||||||
|
rtest.Assert(t, err != nil, "Expected error while backing up")
|
||||||
|
|
||||||
|
testListSnapshots(t, env.gopts, 0)
|
||||||
|
|
||||||
|
testRunCheck(t, env.gopts)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue