func TestLockStale(t *testing.T) { for i, test := range staleLockTests { lock := restic.Lock{ Time: test.timestamp, PID: test.pid, } Assert(t, lock.Stale() == test.stale, "TestStaleLock: test %d failed: expected stale: %v, got %v", i, test.stale, !test.stale) } }
func TestLockStale(t *testing.T) { hostname, err := os.Hostname() OK(t, err) otherHostname := "other-" + hostname for i, test := range staleLockTests { lock := restic.Lock{ Time: test.timestamp, PID: test.pid, Hostname: hostname, } Assert(t, lock.Stale() == test.stale, "TestStaleLock: test %d failed: expected stale: %v, got %v", i, test.stale, !test.stale) lock.Hostname = otherHostname Assert(t, lock.Stale() == test.staleOnOtherHost, "TestStaleLock: test %d failed: expected staleOnOtherHost: %v, got %v", i, test.staleOnOtherHost, !test.staleOnOtherHost) } }