Commit 987c1df0 authored by Sebastian Stark's avatar Sebastian Stark

add tests for different rsync exit values

parent e1ed65ea
......@@ -3,6 +3,8 @@
package main
import (
"os"
"path/filepath"
"reflect"
"testing"
"time"
......@@ -27,3 +29,39 @@ func TestCreateRsyncCommand(t *testing.T) {
t.Errorf("wanted %v, got %v", wanted, got)
}
}
func TestFakeRsyncOk(t *testing.T) {
var testSnapshots = snapshotList{
{time.Unix(1400337531, 0), time.Unix(1400338693, 0), stateComplete},
{time.Unix(1400534523, 0), time.Unix(0, 0), stateIncomplete},
}
var config = config
config.repository = "/tmp/snaprd_dest"
config.ReadCache()
dir, _ := os.Getwd()
config.RsyncPath = filepath.Join(dir, "fake_rsync")
config.RsyncOpts.Set("--fake_exit=24")
_, err := createSnapshot(testSnapshots[0])
got := err
if got != nil {
t.Errorf("createSnapshot() returned an error, but it shouldn't: %v", got)
}
}
func TestFakeRsyncFail(t *testing.T) {
var testSnapshots = snapshotList{
{time.Unix(1400337531, 0), time.Unix(1400338693, 0), stateComplete},
{time.Unix(1400534523, 0), time.Unix(0, 0), stateIncomplete},
}
var config = config
config.repository = "/tmp/snaprd_dest"
config.ReadCache()
dir, _ := os.Getwd()
config.RsyncPath = filepath.Join(dir, "fake_rsync")
config.RsyncOpts.Set("--fake_exit=3")
_, err := createSnapshot(testSnapshots[0])
got := err
if got == nil {
t.Errorf("createSnapshot() succeded, but it should have failed: %v", got)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment