@@ -22,76 +22,6 @@ const FAKE_STATUS_CODE = 1;
22
22
const error = new Error ( ) ;
23
23
error . code = FAKE_STATUS_CODE ;
24
24
25
- describe ( 'PredictionServiceClient' , ( ) => {
26
- describe ( 'predict' , ( ) => {
27
- it ( 'invokes predict without error' , done => {
28
- const client = new automlModule . v1beta1 . PredictionServiceClient ( {
29
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
30
- projectId : 'bogus' ,
31
- } ) ;
32
-
33
- // Mock request
34
- const formattedName = client . modelPath (
35
- '[PROJECT]' ,
36
- '[LOCATION]' ,
37
- '[MODEL]'
38
- ) ;
39
- const payload = { } ;
40
- const request = {
41
- name : formattedName ,
42
- payload : payload ,
43
- } ;
44
-
45
- // Mock response
46
- const expectedResponse = { } ;
47
-
48
- // Mock Grpc layer
49
- client . _innerApiCalls . predict = mockSimpleGrpcMethod (
50
- request ,
51
- expectedResponse
52
- ) ;
53
-
54
- client . predict ( request , ( err , response ) => {
55
- assert . ifError ( err ) ;
56
- assert . deepStrictEqual ( response , expectedResponse ) ;
57
- done ( ) ;
58
- } ) ;
59
- } ) ;
60
-
61
- it ( 'invokes predict with error' , done => {
62
- const client = new automlModule . v1beta1 . PredictionServiceClient ( {
63
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
64
- projectId : 'bogus' ,
65
- } ) ;
66
-
67
- // Mock request
68
- const formattedName = client . modelPath (
69
- '[PROJECT]' ,
70
- '[LOCATION]' ,
71
- '[MODEL]'
72
- ) ;
73
- const payload = { } ;
74
- const request = {
75
- name : formattedName ,
76
- payload : payload ,
77
- } ;
78
-
79
- // Mock Grpc layer
80
- client . _innerApiCalls . predict = mockSimpleGrpcMethod (
81
- request ,
82
- null ,
83
- error
84
- ) ;
85
-
86
- client . predict ( request , ( err , response ) => {
87
- assert ( err instanceof Error ) ;
88
- assert . strictEqual ( err . code , FAKE_STATUS_CODE ) ;
89
- assert ( typeof response === 'undefined' ) ;
90
- done ( ) ;
91
- } ) ;
92
- } ) ;
93
- } ) ;
94
- } ) ;
95
25
describe ( 'AutoMlClient' , ( ) => {
96
26
describe ( 'createDataset' , ( ) => {
97
27
it ( 'invokes createDataset without error' , done => {
@@ -1215,6 +1145,76 @@ describe('AutoMlClient', () => {
1215
1145
} ) ;
1216
1146
} ) ;
1217
1147
} ) ;
1148
+ describe ( 'PredictionServiceClient' , ( ) => {
1149
+ describe ( 'predict' , ( ) => {
1150
+ it ( 'invokes predict without error' , done => {
1151
+ const client = new automlModule . v1beta1 . PredictionServiceClient ( {
1152
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
1153
+ projectId : 'bogus' ,
1154
+ } ) ;
1155
+
1156
+ // Mock request
1157
+ const formattedName = client . modelPath (
1158
+ '[PROJECT]' ,
1159
+ '[LOCATION]' ,
1160
+ '[MODEL]'
1161
+ ) ;
1162
+ const payload = { } ;
1163
+ const request = {
1164
+ name : formattedName ,
1165
+ payload : payload ,
1166
+ } ;
1167
+
1168
+ // Mock response
1169
+ const expectedResponse = { } ;
1170
+
1171
+ // Mock Grpc layer
1172
+ client . _innerApiCalls . predict = mockSimpleGrpcMethod (
1173
+ request ,
1174
+ expectedResponse
1175
+ ) ;
1176
+
1177
+ client . predict ( request , ( err , response ) => {
1178
+ assert . ifError ( err ) ;
1179
+ assert . deepStrictEqual ( response , expectedResponse ) ;
1180
+ done ( ) ;
1181
+ } ) ;
1182
+ } ) ;
1183
+
1184
+ it ( 'invokes predict with error' , done => {
1185
+ const client = new automlModule . v1beta1 . PredictionServiceClient ( {
1186
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
1187
+ projectId : 'bogus' ,
1188
+ } ) ;
1189
+
1190
+ // Mock request
1191
+ const formattedName = client . modelPath (
1192
+ '[PROJECT]' ,
1193
+ '[LOCATION]' ,
1194
+ '[MODEL]'
1195
+ ) ;
1196
+ const payload = { } ;
1197
+ const request = {
1198
+ name : formattedName ,
1199
+ payload : payload ,
1200
+ } ;
1201
+
1202
+ // Mock Grpc layer
1203
+ client . _innerApiCalls . predict = mockSimpleGrpcMethod (
1204
+ request ,
1205
+ null ,
1206
+ error
1207
+ ) ;
1208
+
1209
+ client . predict ( request , ( err , response ) => {
1210
+ assert ( err instanceof Error ) ;
1211
+ assert . strictEqual ( err . code , FAKE_STATUS_CODE ) ;
1212
+ assert ( typeof response === 'undefined' ) ;
1213
+ done ( ) ;
1214
+ } ) ;
1215
+ } ) ;
1216
+ } ) ;
1217
+ } ) ;
1218
1218
1219
1219
function mockSimpleGrpcMethod ( expectedRequest , response , error ) {
1220
1220
return function ( actualRequest , options , callback ) {
0 commit comments