package kubeprobes import ( "testing" ) func TestStatusQueryIsAllGreen(t *testing.T) { var ( probePassing, _ = NewProbeFunction("pass", func() error { return nil }, 0) probeFailing, _ = NewProbeFunction("fail", func() error { return errProbeFailed }, 0) ) tests := map[string]struct { probes []ProbeFunction expectedStatus bool }{ "all green": { probes: []ProbeFunction{probePassing}, expectedStatus: true, }, "some failed": { probes: []ProbeFunction{probePassing, probeFailing}, expectedStatus: false, }, "all failed": { probes: []ProbeFunction{probeFailing}, expectedStatus: false, }, } for name, test := range tests { t.Run(name, func(t *testing.T) { sq := newStatusQuery(test.probes) sq.wait() if sq.ok != test.expectedStatus { t.Errorf("expected status %v, got %v", test.expectedStatus, sq.ok) } }) } }