mirror of
https://github.com/kubereboot/kured.git
synced 2026-08-23 21:36:33 +00:00
29 lines
555 B
Go
29 lines
555 B
Go
package daemonsetlock
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestTtlExpired(t *testing.T) {
|
|
d := time.Date(2020, 05, 05, 14, 15, 0, 0, time.UTC)
|
|
second, _ := time.ParseDuration("1s")
|
|
zero, _ := time.ParseDuration("0m")
|
|
|
|
tests := []struct {
|
|
created time.Time
|
|
ttl time.Duration
|
|
result bool
|
|
}{
|
|
{d, second, true},
|
|
{time.Now(), second, false},
|
|
{d, zero, false},
|
|
}
|
|
|
|
for i, tst := range tests {
|
|
if ttlExpired(tst.created, tst.ttl) != tst.result {
|
|
t.Errorf("Test %d failed, expected %v but got %v", i, tst.result, !tst.result)
|
|
}
|
|
}
|
|
}
|