MCPcopy Create free account
hub / github.com/crossplane-contrib/function-patch-and-transform / TestIsReady

Function TestIsReady

ready_test.go:20–367  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18var _ ReadinessChecker = ReadinessCheckerFn(IsReady)
19
20func TestIsReady(t *testing.T) {
21 type args struct {
22 ctx context.Context
23 o ConditionedObject
24 rc []v1beta1.ReadinessCheck
25 }
26 type want struct {
27 ready bool
28 err error
29 }
30 cases := map[string]struct {
31 reason string
32 args
33 want
34 }{
35 "NoCustomCheckReady": {
36 reason: "If no custom check is given, Ready condition should be used",
37 args: args{
38 o: composed.New(composed.WithConditions(xpv1.Available())),
39 },
40 want: want{
41 ready: true,
42 },
43 },
44 "NoCustomCheckNotReady": {
45 reason: "If no custom check is given, Ready condition should be used",
46 args: args{
47 o: composed.New(composed.WithConditions(xpv1.Unavailable())),
48 },
49 want: want{
50 ready: false,
51 },
52 },
53 "MatchConditionReady": {
54 reason: "If a match condition is explicitly specified it should be used",
55 args: args{
56 o: composed.New(composed.WithConditions(xpv1.Available())),
57 rc: []v1beta1.ReadinessCheck{{
58 Type: v1beta1.ReadinessCheckTypeMatchCondition,
59 MatchCondition: &v1beta1.MatchConditionReadinessCheck{
60 Type: xpv1.TypeReady,
61 Status: corev1.ConditionTrue,
62 },
63 }},
64 },
65 want: want{
66 ready: true,
67 },
68 },
69 "MatchConditionNotReady": {
70 reason: "If a match condition is explicitly specified it should be used",
71 args: args{
72 o: composed.New(composed.WithConditions(xpv1.Unavailable())),
73 rc: []v1beta1.ReadinessCheck{{
74 Type: v1beta1.ReadinessCheckTypeMatchCondition,
75 MatchCondition: &v1beta1.MatchConditionReadinessCheck{
76 Type: xpv1.TypeReady,
77 Status: corev1.ConditionTrue,

Callers

nothing calls this directly

Calls 2

IsReadyFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected