@@ -3,8 +3,12 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
3
3
import { TelemetryEvents } from 'src/constants' ;
4
4
import { InternalServerErrorException } from '@nestjs/common' ;
5
5
import { CloudAutodiscoveryAnalytics } from 'src/modules/cloud/autodiscovery/cloud-autodiscovery.analytics' ;
6
- import { CloudDatabaseStatus , CloudSubscriptionStatus } from 'src/modules/cloud/autodiscovery/models' ;
7
- import { mockCloudDatabase , mockCloudSubscription } from 'src/__mocks__' ;
6
+ import {
7
+ CloudDatabaseStatus ,
8
+ CloudSubscriptionStatus ,
9
+ CloudSubscriptionType
10
+ } from 'src/modules/cloud/autodiscovery/models' ;
11
+ import { mockCloudDatabase , mockCloudDatabaseFixed , mockCloudSubscription } from 'src/__mocks__' ;
8
12
9
13
describe ( 'CloudAutodiscoveryAnalytics' , ( ) => {
10
14
let service : CloudAutodiscoveryAnalytics ;
@@ -36,13 +40,14 @@ describe('CloudAutodiscoveryAnalytics', () => {
36
40
service . sendGetRECloudSubsSucceedEvent ( [
37
41
mockCloudSubscription ,
38
42
mockCloudSubscription ,
39
- ] ) ;
43
+ ] , CloudSubscriptionType . Flexible ) ;
40
44
41
45
expect ( sendEventMethod ) . toHaveBeenCalledWith (
42
46
TelemetryEvents . RECloudSubscriptionsDiscoverySucceed ,
43
47
{
44
48
numberOfActiveSubscriptions : 2 ,
45
49
totalNumberOfSubscriptions : 2 ,
50
+ type : CloudSubscriptionType . Flexible ,
46
51
} ,
47
52
) ;
48
53
} ) ;
@@ -53,13 +58,14 @@ describe('CloudAutodiscoveryAnalytics', () => {
53
58
status : CloudSubscriptionStatus . Error ,
54
59
} ,
55
60
mockCloudSubscription ,
56
- ] ) ;
61
+ ] , CloudSubscriptionType . Flexible ) ;
57
62
58
63
expect ( sendEventMethod ) . toHaveBeenCalledWith (
59
64
TelemetryEvents . RECloudSubscriptionsDiscoverySucceed ,
60
65
{
61
66
numberOfActiveSubscriptions : 1 ,
62
67
totalNumberOfSubscriptions : 2 ,
68
+ type : CloudSubscriptionType . Flexible ,
63
69
} ,
64
70
) ;
65
71
} ) ;
@@ -73,52 +79,56 @@ describe('CloudAutodiscoveryAnalytics', () => {
73
79
...mockCloudSubscription ,
74
80
status : CloudSubscriptionStatus . Error ,
75
81
} ,
76
- ] ) ;
82
+ ] , CloudSubscriptionType . Flexible ) ;
77
83
expect ( sendEventMethod ) . toHaveBeenCalledWith (
78
84
TelemetryEvents . RECloudSubscriptionsDiscoverySucceed ,
79
85
{
80
86
numberOfActiveSubscriptions : 0 ,
81
87
totalNumberOfSubscriptions : 2 ,
88
+ type : CloudSubscriptionType . Flexible ,
82
89
} ,
83
90
) ;
84
91
} ) ;
85
92
it ( 'should emit GetRECloudSubsSucceedEvent event for empty list' , ( ) => {
86
- service . sendGetRECloudSubsSucceedEvent ( [ ] ) ;
93
+ service . sendGetRECloudSubsSucceedEvent ( [ ] , CloudSubscriptionType . Flexible ) ;
87
94
88
95
expect ( sendEventMethod ) . toHaveBeenCalledWith (
89
96
TelemetryEvents . RECloudSubscriptionsDiscoverySucceed ,
90
97
{
91
98
numberOfActiveSubscriptions : 0 ,
92
99
totalNumberOfSubscriptions : 0 ,
100
+ type : CloudSubscriptionType . Flexible ,
93
101
} ,
94
102
) ;
95
103
} ) ;
96
104
it ( 'should emit GetRECloudSubsSucceedEvent event for undefined input value' , ( ) => {
97
- service . sendGetRECloudSubsSucceedEvent ( undefined ) ;
105
+ service . sendGetRECloudSubsSucceedEvent ( undefined , CloudSubscriptionType . Fixed ) ;
98
106
99
107
expect ( sendEventMethod ) . toHaveBeenCalledWith (
100
108
TelemetryEvents . RECloudSubscriptionsDiscoverySucceed ,
101
109
{
102
110
numberOfActiveSubscriptions : 0 ,
103
111
totalNumberOfSubscriptions : 0 ,
112
+ type : CloudSubscriptionType . Fixed ,
104
113
} ,
105
114
) ;
106
115
} ) ;
107
116
it ( 'should not throw on error when sending GetRECloudSubsSucceedEvent event' , ( ) => {
108
117
const input : any = { } ;
109
118
110
- expect ( ( ) => service . sendGetRECloudSubsSucceedEvent ( input ) ) . not . toThrow ( ) ;
119
+ expect ( ( ) => service . sendGetRECloudSubsSucceedEvent ( input , CloudSubscriptionType . Flexible ) ) . not . toThrow ( ) ;
111
120
expect ( sendEventMethod ) . not . toHaveBeenCalled ( ) ;
112
121
} ) ;
113
122
} ) ;
114
123
115
124
describe ( 'sendGetRECloudSubsFailedEvent' , ( ) => {
116
125
it ( 'should emit GetRECloudSubsFailedEvent event' , ( ) => {
117
- service . sendGetRECloudSubsFailedEvent ( httpException ) ;
126
+ service . sendGetRECloudSubsFailedEvent ( httpException , CloudSubscriptionType . Fixed ) ;
118
127
119
128
expect ( sendFailedEventMethod ) . toHaveBeenCalledWith (
120
129
TelemetryEvents . RECloudSubscriptionsDiscoveryFailed ,
121
130
httpException ,
131
+ { type : CloudSubscriptionType . Fixed } ,
122
132
) ;
123
133
} ) ;
124
134
} ) ;
@@ -127,14 +137,16 @@ describe('CloudAutodiscoveryAnalytics', () => {
127
137
it ( 'should emit event with active databases' , ( ) => {
128
138
service . sendGetRECloudDbsSucceedEvent ( [
129
139
mockCloudDatabase ,
130
- mockCloudDatabase ,
140
+ mockCloudDatabaseFixed ,
131
141
] ) ;
132
142
133
143
expect ( sendEventMethod ) . toHaveBeenCalledWith (
134
144
TelemetryEvents . RECloudDatabasesDiscoverySucceed ,
135
145
{
136
146
numberOfActiveDatabases : 2 ,
137
147
totalNumberOfDatabases : 2 ,
148
+ fixed : 1 ,
149
+ flexible : 1 ,
138
150
} ,
139
151
) ;
140
152
} ) ;
@@ -152,6 +164,8 @@ describe('CloudAutodiscoveryAnalytics', () => {
152
164
{
153
165
numberOfActiveDatabases : 1 ,
154
166
totalNumberOfDatabases : 2 ,
167
+ fixed : 0 ,
168
+ flexible : 2 ,
155
169
} ,
156
170
) ;
157
171
} ) ;
@@ -168,6 +182,8 @@ describe('CloudAutodiscoveryAnalytics', () => {
168
182
{
169
183
numberOfActiveDatabases : 0 ,
170
184
totalNumberOfDatabases : 1 ,
185
+ fixed : 0 ,
186
+ flexible : 1 ,
171
187
} ,
172
188
) ;
173
189
} ) ;
@@ -179,6 +195,8 @@ describe('CloudAutodiscoveryAnalytics', () => {
179
195
{
180
196
numberOfActiveDatabases : 0 ,
181
197
totalNumberOfDatabases : 0 ,
198
+ fixed : 0 ,
199
+ flexible : 0 ,
182
200
} ,
183
201
) ;
184
202
} ) ;
@@ -190,6 +208,8 @@ describe('CloudAutodiscoveryAnalytics', () => {
190
208
{
191
209
numberOfActiveDatabases : 0 ,
192
210
totalNumberOfDatabases : 0 ,
211
+ fixed : 0 ,
212
+ flexible : 0 ,
193
213
} ,
194
214
) ;
195
215
} ) ;
0 commit comments