aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/earlyinit/uevent_test.go
blob: d4b771417e9c1997d933a6b8d0b3842aac715e89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main

import (
	"testing"
	"testing/synctest"
	"time"
)

func TestRejectColdboot(t *testing.T) {
	t.Parallel()

	synctest.Test(t, func(t *testing.T) {
		nextColdboot := newRejectColdboot()
		want := func(want bool) {
			if got := nextColdboot(); got != want {
				t.Fatalf("nextColdboot: %v, want %v", got, want)
			}
		}

		synctest.Wait()
		want(true)
		time.Sleep(time.Hour)
		synctest.Wait()
		want(true)
		want(true)
		time.Sleep(5 * time.Minute)
		synctest.Wait()
		want(true)
		want(false)
		time.Sleep(time.Hour)
		synctest.Wait()
		want(false)
		want(false)
	})
}