@@ -20,13 +20,50 @@ type conditionMatcher[T comparable] struct {
2020	expected  * ConditionImpl [T ]
2121}
2222
23+ func  (c  * conditionMatcher [T ]) GomegaString () string  {
24+ 	if  c  ==  nil  ||  c .expected  ==  nil  {
25+ 		return  "<nil>" 
26+ 	}
27+ 	return  c .expected .String ()
28+ }
29+ 
2330var  _  types.GomegaMatcher  =  & conditionMatcher [bool ]{}
2431
2532// Match implements types.GomegaMatcher. 
26- func  (c  * conditionMatcher [T ]) Match (actualRaw  interface {}) (success  bool , err  error ) {
27- 	actual , ok  :=  actualRaw .(conditions.Condition [T ])
28- 	if  ! ok  {
29- 		return  false , fmt .Errorf ("expected actual to be of type Condition[%s], got %T" , reflect .TypeFor [T ]().Name (), actualRaw )
33+ func  (c  * conditionMatcher [T ]) Match (actualRaw  any ) (success  bool , err  error ) {
34+ 	actual , converted  :=  actualRaw .(conditions.Condition [T ])
35+ 	if  ! converted  {
36+ 		// actualRaw doesn't implement conditions.Condition[T], check if a pointer to it does 
37+ 		ptrValue  :=  reflect .New (reflect .TypeOf (actualRaw ))
38+ 		reflect .Indirect (ptrValue ).Set (reflect .ValueOf (actualRaw ))
39+ 		actual , converted  =  ptrValue .Interface ().(conditions.Condition [T ])
40+ 	}
41+ 	if  ! converted  {
42+ 		return  false , fmt .Errorf ("expected actual (or &actual) to be of type Condition[%s], got %T" , reflect .TypeFor [T ]().Name (), actualRaw )
43+ 	}
44+ 	// if aVal.CanConvert(conImplType) { 
45+ 	// 	actual = aVal.Convert(conImplType).Interface().(conditions.Condition[T]) 
46+ 	// } else if aVal.Kind() == reflect.Struct { 
47+ 	// 	p := reflect.PointerTo() 
48+ 	// 	actual = aVal.Addr().Convert(conImplType).Interface().(conditions.Condition[T]) 
49+ 	// } else { 
50+ 	// 	return false, fmt.Errorf("expected actual to be of type Condition[%s], got %T", reflect.TypeFor[T]().Name(), actualRaw) 
51+ 	// } 
52+ 	// actual, ok := actualRaw.(conditions.Condition[T]) 
53+ 	// if !ok { 
54+ 	// 	// check if actualRaw is a valid Condition if a pointer to it is used instead 
55+ 	// 	tmp, ok := actualRaw.(*conditions.Condition[T]) 
56+ 	// 	if ok { 
57+ 	// 		actual = *tmp 
58+ 	// 	} else { 
59+ 	// 		return false, fmt.Errorf("expected actual to be of type Condition[%s], got %T", reflect.TypeFor[T]().Name(), actualRaw) 
60+ 	// 	} 
61+ 	// } 
62+ 	if  actual  ==  nil  &&  c .expected  ==  nil  {
63+ 		return  true , nil 
64+ 	}
65+ 	if  actual  ==  nil  ||  c .expected  ==  nil  {
66+ 		return  false , nil 
3067	}
3168	if  c .expected .HasType () &&  c .expected .GetType () !=  actual .GetType () {
3269		return  false , nil 
@@ -86,6 +123,39 @@ type ConditionImpl[T comparable] struct {
86123	lastTransitionTime  * time.Time 
87124}
88125
126+ func  (c  * ConditionImpl [T ]) String () string  {
127+ 	if  c  ==  nil  {
128+ 		return  "<nil>" 
129+ 	}
130+ 	var  status , conType , reason , message , lastTransitionTime  string 
131+ 	if  c .status  ==  nil  {
132+ 		status  =  "<arbitrary>" 
133+ 	} else  {
134+ 		status  =  fmt .Sprintf ("%v" , * c .status )
135+ 	}
136+ 	if  c .conType  ==  nil  {
137+ 		conType  =  "<arbitrary>" 
138+ 	} else  {
139+ 		conType  =  * c .conType 
140+ 	}
141+ 	if  c .reason  ==  nil  {
142+ 		reason  =  "<arbitrary>" 
143+ 	} else  {
144+ 		reason  =  * c .reason 
145+ 	}
146+ 	if  c .message  ==  nil  {
147+ 		message  =  "<arbitrary>" 
148+ 	} else  {
149+ 		message  =  * c .message 
150+ 	}
151+ 	if  c .lastTransitionTime  ==  nil  {
152+ 		lastTransitionTime  =  "<arbitrary>" 
153+ 	} else  {
154+ 		lastTransitionTime  =  c .lastTransitionTime .Format (time .RFC3339 )
155+ 	}
156+ 	return  fmt .Sprintf ("Condition[%s]{\n \t Type: %q,\n \t Status: %s,\n \t Reason: %q,\n \t Message: %q,\n \t LastTransitionTime: %v,\n }" , reflect .TypeFor [T ]().Name (), conType , status , reason , message , lastTransitionTime )
157+ }
158+ 
89159var  _  conditions.Condition [bool ] =  & ConditionImpl [bool ]{}
90160
91161func  (c  * ConditionImpl [T ]) GetLastTransitionTime () time.Time  {
0 commit comments