@@ -25,15 +25,16 @@ public class EventPublisherIntegrationTest : IntegrationTestBase
25
25
[ Fact ]
26
26
public async Task Should_Create_New_Event ( )
27
27
{
28
- var eventName = $ "single-entity.{ _ns . Namespace } .REASON.message.Normal";
28
+ var entity =
29
+ await _client . CreateAsync ( new V1OperatorIntegrationTestEntity ( "single-entity" , "username" , _ns . Namespace ) ) ;
30
+ await _mock . WaitForInvocations ;
31
+
32
+ var eventName = $ "{ entity . Uid ( ) } .single-entity.{ _ns . Namespace } .REASON.message.Normal";
29
33
var encodedEventName =
30
34
Convert . ToHexString (
31
35
SHA512 . HashData (
32
36
Encoding . UTF8 . GetBytes ( eventName ) ) ) ;
33
37
34
- await _client . CreateAsync ( new V1OperatorIntegrationTestEntity ( "single-entity" , "username" , _ns . Namespace ) ) ;
35
- await _mock . WaitForInvocations ;
36
-
37
38
var e = await _client . GetAsync < Corev1Event > ( encodedEventName , _ns . Namespace ) ;
38
39
e ! . Count . Should ( ) . Be ( 1 ) ;
39
40
e . Metadata . Annotations . Should ( ) . Contain ( a => a . Key == "originalName" && a . Value == eventName ) ;
@@ -43,15 +44,16 @@ public async Task Should_Create_New_Event()
43
44
public async Task Should_Increase_Count_On_Existing_Event ( )
44
45
{
45
46
_mock . TargetInvocationCount = 5 ;
46
- var eventName = $ "test-entity.{ _ns . Namespace } .REASON.message.Normal";
47
+ var entity =
48
+ await _client . CreateAsync ( new V1OperatorIntegrationTestEntity ( "test-entity" , "username" , _ns . Namespace ) ) ;
49
+ await _mock . WaitForInvocations ;
50
+
51
+ var eventName = $ "{ entity . Uid ( ) } .test-entity.{ _ns . Namespace } .REASON.message.Normal";
47
52
var encodedEventName =
48
53
Convert . ToHexString (
49
54
SHA512 . HashData (
50
55
Encoding . UTF8 . GetBytes ( eventName ) ) ) ;
51
56
52
- await _client . CreateAsync ( new V1OperatorIntegrationTestEntity ( "test-entity" , "username" , _ns . Namespace ) ) ;
53
- await _mock . WaitForInvocations ;
54
-
55
57
var e = await _client . GetAsync < Corev1Event > ( encodedEventName , _ns . Namespace ) ;
56
58
e ! . Count . Should ( ) . Be ( 5 ) ;
57
59
e . Metadata . Annotations . Should ( ) . Contain ( a => a . Key == "originalName" && a . Value == eventName ) ;
@@ -78,9 +80,10 @@ protected override void ConfigureHost(HostApplicationBuilder builder)
78
80
. AddController < TestController , V1OperatorIntegrationTestEntity > ( ) ;
79
81
}
80
82
81
- private class TestController ( InvocationCounter < V1OperatorIntegrationTestEntity > svc ,
82
- EntityRequeue < V1OperatorIntegrationTestEntity > requeue ,
83
- EventPublisher eventPublisher )
83
+ private class TestController (
84
+ InvocationCounter < V1OperatorIntegrationTestEntity > svc ,
85
+ EntityRequeue < V1OperatorIntegrationTestEntity > requeue ,
86
+ EventPublisher eventPublisher )
84
87
: IEntityController < V1OperatorIntegrationTestEntity >
85
88
{
86
89
public async Task ReconcileAsync ( V1OperatorIntegrationTestEntity entity )
0 commit comments