@@ -38,86 +38,25 @@ describe('http/actors', () => {
38
38
await server . startServer ( ) ; // Start the general server
39
39
} ) ;
40
40
41
- describe ( 'activation/deactivation' , ( ) => {
42
- it ( 'should correctly deactivate and activate an actor' , async ( ) => {
43
- // An actor is activated when we create the object and it has been added to the tracking table
44
- // for a good E2E test we thus check:
45
- // * has it been added to the tracking table?
46
- // -> Indirectly, we expect this by calling the Dapr client, which should be able to find the Actor in its tracking table
47
- // -> we thus use the client rather than the server methods
48
- // * has the method onActivate been called on the implemented actor?
49
- // -> create a specific actor implementation for this, since it's threaded and hard to mock else
50
-
51
- // Reset state store
52
- // for this we activate and deactivate the actor first so we know it exists
53
- await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getIsActivated" ) ;
54
- await server . actor . deactivateActor ( DemoActorActivateImpl . name , "my-actor-id" ) ;
55
- await client . actor . stateTransaction ( DemoActorActivateImpl . name , "my-actor-id" , [
56
- {
57
- operation : "upsert" ,
58
- request : {
59
- key : "is_activated" ,
60
- value : false
61
- }
62
- } ,
63
- {
64
- operation : "upsert" ,
65
- request : {
66
- key : "is_deactivated" ,
67
- value : false
68
- }
69
- } ,
70
- {
71
- operation : "upsert" ,
72
- request : {
73
- key : "call_count_activated" ,
74
- value : 0
75
- }
76
- } ,
77
- {
78
- operation : "upsert" ,
79
- request : {
80
- key : "call_count_deactivated" ,
81
- value : 0
82
- }
83
- } ,
84
- ] ) ;
85
-
86
- // Activate Actor
87
- const res1 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getIsDeactivated" ) ;
88
- const res2 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getIsActivated" ) ;
89
- const res3 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getDeactivatedCallCount" ) ;
90
- const res4 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getActivatedCallCount" ) ;
91
- expect ( res1 ) . toEqual ( false ) ;
92
- expect ( res2 ) . toEqual ( true ) ;
93
- expect ( res3 ) . toEqual ( 0 ) ;
94
- expect ( res4 ) . toEqual ( 1 ) ;
95
-
96
- // Deactivate Actor
97
- await server . actor . deactivateActor ( DemoActorActivateImpl . name , "my-actor-id" ) ;
98
-
99
- // Now call the getIsDeactivated and getDeactivatedCallCount again, which should change since it was deactivated
100
- // note: it will be reactivated again now since we call the invoke
101
- const res5 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getIsDeactivated" ) ;
102
- const res6 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getIsActivated" ) ;
103
- const res7 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getDeactivatedCallCount" ) ;
104
- const res8 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getActivatedCallCount" ) ;
105
- expect ( res5 ) . toEqual ( true ) ;
106
- expect ( res6 ) . toEqual ( true ) ;
107
- expect ( res7 ) . toEqual ( 1 ) ;
108
- expect ( res8 ) . toEqual ( 2 ) ;
109
-
110
- // Deactivate Actor
111
- await server . actor . deactivateActor ( DemoActorActivateImpl . name , "my-actor-id" ) ;
112
-
113
- const res9 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getIsDeactivated" ) ;
114
- const res10 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getIsActivated" ) ;
115
- const res11 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getDeactivatedCallCount" ) ;
116
- const res12 = await client . actor . invoke ( "GET" , DemoActorActivateImpl . name , "my-actor-id" , "getActivatedCallCount" ) ;
117
- expect ( res9 ) . toEqual ( true ) ;
118
- expect ( res10 ) . toEqual ( true ) ;
119
- expect ( res11 ) . toEqual ( 2 ) ;
120
- expect ( res12 ) . toEqual ( 3 ) ;
41
+ afterAll ( async ( ) => {
42
+ await server . stopServer ( ) ;
43
+ } ) ;
44
+
45
+ describe ( 'actorProxy' , ( ) => {
46
+ it ( 'should be able to create an actor object through the proxy' , async ( ) => {
47
+ const builder = new ActorProxyBuilder < DemoActorCounterImpl > ( DemoActorCounterImpl , client ) ;
48
+ const actor = builder . build ( ActorId . createRandomId ( ) ) ;
49
+
50
+ const c1 = await actor . getCounter ( ) ;
51
+ expect ( c1 ) . toEqual ( 0 ) ;
52
+
53
+ await actor . countBy ( 1 ) ;
54
+ const c2 = await actor . getCounter ( ) ;
55
+ expect ( c2 ) . toEqual ( 1 ) ;
56
+
57
+ await actor . countBy ( 5 ) ;
58
+ const c3 = await actor . getCounter ( ) ;
59
+ expect ( c3 ) . toEqual ( 6 ) ;
121
60
} ) ;
122
61
} ) ;
123
62
0 commit comments