github.com/pachyderm/pachyderm@v1.13.4/src/server/pkg/testpachd/mock_pachd.go (about) 1 package testpachd 2 3 import ( 4 "context" 5 "net" 6 "reflect" 7 8 "github.com/gogo/protobuf/types" 9 10 "github.com/pachyderm/pachyderm/src/client/admin" 11 "github.com/pachyderm/pachyderm/src/client/auth" 12 "github.com/pachyderm/pachyderm/src/client/enterprise" 13 "github.com/pachyderm/pachyderm/src/client/pfs" 14 "github.com/pachyderm/pachyderm/src/client/pkg/errors" 15 "github.com/pachyderm/pachyderm/src/client/pkg/grpcutil" 16 "github.com/pachyderm/pachyderm/src/client/pps" 17 "github.com/pachyderm/pachyderm/src/client/transaction" 18 version "github.com/pachyderm/pachyderm/src/client/version/versionpb" 19 ) 20 21 // linkServers can be used to default a mock server to make calls to a real api 22 // server. Due to some reflection shenanigans, mockServerPtr must explicitly be 23 // a pointer to the mock server instance. 24 func linkServers(mockServerPtr interface{}, realServer interface{}) { 25 mockValue := reflect.ValueOf(mockServerPtr).Elem() 26 realValue := reflect.ValueOf(realServer) 27 mockType := mockValue.Type() 28 for i := 0; i < mockType.NumField(); i++ { 29 field := mockType.Field(i) 30 if field.Name != "api" { 31 mock := mockValue.FieldByName(field.Name) 32 realMethod := realValue.MethodByName(field.Name) 33 34 // We need a pointer to the mock field to call the right method 35 mockPtr := reflect.New(reflect.PtrTo(mock.Type())) 36 mockPtrValue := mockPtr.Elem() 37 mockPtrValue.Set(mock.Addr()) 38 39 useFn := mockPtrValue.MethodByName("Use") 40 useFn.Call([]reflect.Value{realMethod}) 41 } 42 } 43 } 44 45 /* Admin Server Mocks */ 46 47 type extractFunc func(*admin.ExtractRequest, admin.API_ExtractServer) error 48 type extractPipelineFunc func(context.Context, *admin.ExtractPipelineRequest) (*admin.Op, error) 49 type restoreFunc func(admin.API_RestoreServer) error 50 type inspectClusterFunc func(context.Context, *types.Empty) (*admin.ClusterInfo, error) 51 52 type mockExtract struct{ handler extractFunc } 53 type mockExtractPipeline struct{ handler extractPipelineFunc } 54 type mockRestore struct{ handler restoreFunc } 55 type mockInspectCluster struct{ handler inspectClusterFunc } 56 57 func (mock *mockExtract) Use(cb extractFunc) { mock.handler = cb } 58 func (mock *mockExtractPipeline) Use(cb extractPipelineFunc) { mock.handler = cb } 59 func (mock *mockRestore) Use(cb restoreFunc) { mock.handler = cb } 60 func (mock *mockInspectCluster) Use(cb inspectClusterFunc) { mock.handler = cb } 61 62 type adminServerAPI struct { 63 mock *mockAdminServer 64 } 65 66 type mockAdminServer struct { 67 api adminServerAPI 68 Extract mockExtract 69 ExtractPipeline mockExtractPipeline 70 Restore mockRestore 71 InspectCluster mockInspectCluster 72 } 73 74 func (api *adminServerAPI) Extract(req *admin.ExtractRequest, serv admin.API_ExtractServer) error { 75 if api.mock.Extract.handler != nil { 76 return api.mock.Extract.handler(req, serv) 77 } 78 return errors.Errorf("unhandled pachd mock: admin.Extract") 79 } 80 func (api *adminServerAPI) ExtractPipeline(ctx context.Context, req *admin.ExtractPipelineRequest) (*admin.Op, error) { 81 if api.mock.ExtractPipeline.handler != nil { 82 return api.mock.ExtractPipeline.handler(ctx, req) 83 } 84 return nil, errors.Errorf("unhandled pachd mock admin.ExtractPipeline") 85 } 86 func (api *adminServerAPI) Restore(serv admin.API_RestoreServer) error { 87 if api.mock.Restore.handler != nil { 88 return api.mock.Restore.handler(serv) 89 } 90 return errors.Errorf("unhandled pachd mock admin.Restore") 91 } 92 func (api *adminServerAPI) InspectCluster(ctx context.Context, req *types.Empty) (*admin.ClusterInfo, error) { 93 if api.mock.InspectCluster.handler != nil { 94 return api.mock.InspectCluster.handler(ctx, req) 95 } 96 return nil, errors.Errorf("unhandled pachd mock admin.InspectCluster") 97 } 98 99 /* Auth Server Mocks */ 100 101 type activateAuthFunc func(context.Context, *auth.ActivateRequest) (*auth.ActivateResponse, error) 102 type deactivateAuthFunc func(context.Context, *auth.DeactivateRequest) (*auth.DeactivateResponse, error) 103 type getConfigurationFunc func(context.Context, *auth.GetConfigurationRequest) (*auth.GetConfigurationResponse, error) 104 type setConfigurationFunc func(context.Context, *auth.SetConfigurationRequest) (*auth.SetConfigurationResponse, error) 105 type getAdminsFunc func(context.Context, *auth.GetAdminsRequest) (*auth.GetAdminsResponse, error) 106 type modifyAdminsFunc func(context.Context, *auth.ModifyAdminsRequest) (*auth.ModifyAdminsResponse, error) 107 type getClusterRoleBindingsFunc func(context.Context, *auth.GetClusterRoleBindingsRequest) (*auth.GetClusterRoleBindingsResponse, error) 108 type modifyClusterRoleBindingFunc func(context.Context, *auth.ModifyClusterRoleBindingRequest) (*auth.ModifyClusterRoleBindingResponse, error) 109 110 type authenticateFunc func(context.Context, *auth.AuthenticateRequest) (*auth.AuthenticateResponse, error) 111 type authorizeFunc func(context.Context, *auth.AuthorizeRequest) (*auth.AuthorizeResponse, error) 112 type whoAmIFunc func(context.Context, *auth.WhoAmIRequest) (*auth.WhoAmIResponse, error) 113 type getScopeFunc func(context.Context, *auth.GetScopeRequest) (*auth.GetScopeResponse, error) 114 type setScopeFunc func(context.Context, *auth.SetScopeRequest) (*auth.SetScopeResponse, error) 115 type getACLFunc func(context.Context, *auth.GetACLRequest) (*auth.GetACLResponse, error) 116 type setACLFunc func(context.Context, *auth.SetACLRequest) (*auth.SetACLResponse, error) 117 type getOIDCLoginFunc func(context.Context, *auth.GetOIDCLoginRequest) (*auth.GetOIDCLoginResponse, error) 118 type getAuthTokenFunc func(context.Context, *auth.GetAuthTokenRequest) (*auth.GetAuthTokenResponse, error) 119 type extendAuthTokenFunc func(context.Context, *auth.ExtendAuthTokenRequest) (*auth.ExtendAuthTokenResponse, error) 120 type revokeAuthTokenFunc func(context.Context, *auth.RevokeAuthTokenRequest) (*auth.RevokeAuthTokenResponse, error) 121 type setGroupsForUserFunc func(context.Context, *auth.SetGroupsForUserRequest) (*auth.SetGroupsForUserResponse, error) 122 type modifyMembersFunc func(context.Context, *auth.ModifyMembersRequest) (*auth.ModifyMembersResponse, error) 123 type getGroupsFunc func(context.Context, *auth.GetGroupsRequest) (*auth.GetGroupsResponse, error) 124 type getUsersFunc func(context.Context, *auth.GetUsersRequest) (*auth.GetUsersResponse, error) 125 type getOneTimePasswordFunc func(context.Context, *auth.GetOneTimePasswordRequest) (*auth.GetOneTimePasswordResponse, error) 126 type extractAuthTokensFunc func(context.Context, *auth.ExtractAuthTokensRequest) (*auth.ExtractAuthTokensResponse, error) 127 type restoreAuthTokenFunc func(context.Context, *auth.RestoreAuthTokenRequest) (*auth.RestoreAuthTokenResponse, error) 128 129 type mockActivateAuth struct{ handler activateAuthFunc } 130 type mockDeactivateAuth struct{ handler deactivateAuthFunc } 131 type mockGetConfiguration struct{ handler getConfigurationFunc } 132 type mockSetConfiguration struct{ handler setConfigurationFunc } 133 type mockGetAdmins struct{ handler getAdminsFunc } 134 type mockModifyAdmins struct{ handler modifyAdminsFunc } 135 type mockModifyClusterRoleBinding struct{ handler modifyClusterRoleBindingFunc } 136 type mockGetClusterRoleBindings struct{ handler getClusterRoleBindingsFunc } 137 type mockAuthenticate struct{ handler authenticateFunc } 138 type mockAuthorize struct{ handler authorizeFunc } 139 type mockWhoAmI struct{ handler whoAmIFunc } 140 type mockGetScope struct{ handler getScopeFunc } 141 type mockSetScope struct{ handler setScopeFunc } 142 type mockGetACL struct{ handler getACLFunc } 143 type mockSetACL struct{ handler setACLFunc } 144 type mockGetOIDCLogin struct{ handler getOIDCLoginFunc } 145 type mockGetAuthToken struct{ handler getAuthTokenFunc } 146 type mockExtendAuthToken struct{ handler extendAuthTokenFunc } 147 type mockRevokeAuthToken struct{ handler revokeAuthTokenFunc } 148 type mockSetGroupsForUser struct{ handler setGroupsForUserFunc } 149 type mockModifyMembers struct{ handler modifyMembersFunc } 150 type mockGetGroups struct{ handler getGroupsFunc } 151 type mockGetUsers struct{ handler getUsersFunc } 152 type mockGetOneTimePassword struct{ handler getOneTimePasswordFunc } 153 type mockExtractAuthTokens struct{ handler extractAuthTokensFunc } 154 type mockRestoreAuthToken struct{ handler restoreAuthTokenFunc } 155 156 func (mock *mockActivateAuth) Use(cb activateAuthFunc) { mock.handler = cb } 157 func (mock *mockDeactivateAuth) Use(cb deactivateAuthFunc) { mock.handler = cb } 158 func (mock *mockGetConfiguration) Use(cb getConfigurationFunc) { mock.handler = cb } 159 func (mock *mockSetConfiguration) Use(cb setConfigurationFunc) { mock.handler = cb } 160 func (mock *mockGetAdmins) Use(cb getAdminsFunc) { mock.handler = cb } 161 func (mock *mockModifyAdmins) Use(cb modifyAdminsFunc) { mock.handler = cb } 162 func (mock *mockModifyClusterRoleBinding) Use(cb modifyClusterRoleBindingFunc) { mock.handler = cb } 163 func (mock *mockGetClusterRoleBindings) Use(cb getClusterRoleBindingsFunc) { mock.handler = cb } 164 func (mock *mockAuthenticate) Use(cb authenticateFunc) { mock.handler = cb } 165 func (mock *mockAuthorize) Use(cb authorizeFunc) { mock.handler = cb } 166 func (mock *mockWhoAmI) Use(cb whoAmIFunc) { mock.handler = cb } 167 func (mock *mockGetScope) Use(cb getScopeFunc) { mock.handler = cb } 168 func (mock *mockSetScope) Use(cb setScopeFunc) { mock.handler = cb } 169 func (mock *mockGetACL) Use(cb getACLFunc) { mock.handler = cb } 170 func (mock *mockSetACL) Use(cb setACLFunc) { mock.handler = cb } 171 func (mock *mockGetOIDCLogin) Use(cb getOIDCLoginFunc) { mock.handler = cb } 172 func (mock *mockGetAuthToken) Use(cb getAuthTokenFunc) { mock.handler = cb } 173 func (mock *mockExtendAuthToken) Use(cb extendAuthTokenFunc) { mock.handler = cb } 174 func (mock *mockRevokeAuthToken) Use(cb revokeAuthTokenFunc) { mock.handler = cb } 175 func (mock *mockSetGroupsForUser) Use(cb setGroupsForUserFunc) { mock.handler = cb } 176 func (mock *mockModifyMembers) Use(cb modifyMembersFunc) { mock.handler = cb } 177 func (mock *mockGetGroups) Use(cb getGroupsFunc) { mock.handler = cb } 178 func (mock *mockGetUsers) Use(cb getUsersFunc) { mock.handler = cb } 179 func (mock *mockGetOneTimePassword) Use(cb getOneTimePasswordFunc) { mock.handler = cb } 180 func (mock *mockExtractAuthTokens) Use(cb extractAuthTokensFunc) { mock.handler = cb } 181 func (mock *mockRestoreAuthToken) Use(cb restoreAuthTokenFunc) { mock.handler = cb } 182 183 type authServerAPI struct { 184 mock *mockAuthServer 185 } 186 187 type mockAuthServer struct { 188 api authServerAPI 189 Activate mockActivateAuth 190 Deactivate mockDeactivateAuth 191 GetConfiguration mockGetConfiguration 192 SetConfiguration mockSetConfiguration 193 GetAdmins mockGetAdmins 194 ModifyAdmins mockModifyAdmins 195 GetClusterRoleBindings mockGetClusterRoleBindings 196 ModifyClusterRoleBinding mockModifyClusterRoleBinding 197 Authenticate mockAuthenticate 198 Authorize mockAuthorize 199 WhoAmI mockWhoAmI 200 GetScope mockGetScope 201 SetScope mockSetScope 202 GetACL mockGetACL 203 SetACL mockSetACL 204 GetOIDCLogin mockGetOIDCLogin 205 GetAuthToken mockGetAuthToken 206 ExtendAuthToken mockExtendAuthToken 207 RevokeAuthToken mockRevokeAuthToken 208 SetGroupsForUser mockSetGroupsForUser 209 ModifyMembers mockModifyMembers 210 GetGroups mockGetGroups 211 GetUsers mockGetUsers 212 GetOneTimePassword mockGetOneTimePassword 213 ExtractAuthTokens mockExtractAuthTokens 214 RestoreAuthToken mockRestoreAuthToken 215 } 216 217 func (api *authServerAPI) Activate(ctx context.Context, req *auth.ActivateRequest) (*auth.ActivateResponse, error) { 218 if api.mock.Activate.handler != nil { 219 return api.mock.Activate.handler(ctx, req) 220 } 221 return nil, errors.Errorf("unhandled pachd mock auth.Activate") 222 } 223 func (api *authServerAPI) Deactivate(ctx context.Context, req *auth.DeactivateRequest) (*auth.DeactivateResponse, error) { 224 if api.mock.Deactivate.handler != nil { 225 return api.mock.Deactivate.handler(ctx, req) 226 } 227 return nil, errors.Errorf("unhandled pachd mock auth.Deactivate") 228 } 229 func (api *authServerAPI) GetConfiguration(ctx context.Context, req *auth.GetConfigurationRequest) (*auth.GetConfigurationResponse, error) { 230 if api.mock.GetConfiguration.handler != nil { 231 return api.mock.GetConfiguration.handler(ctx, req) 232 } 233 return nil, errors.Errorf("unhandled pachd mock auth.GetConfiguration") 234 } 235 func (api *authServerAPI) SetConfiguration(ctx context.Context, req *auth.SetConfigurationRequest) (*auth.SetConfigurationResponse, error) { 236 if api.mock.SetConfiguration.handler != nil { 237 return api.mock.SetConfiguration.handler(ctx, req) 238 } 239 return nil, errors.Errorf("unhandled pachd mock auth.SetConfiguration") 240 } 241 func (api *authServerAPI) GetAdmins(ctx context.Context, req *auth.GetAdminsRequest) (*auth.GetAdminsResponse, error) { 242 if api.mock.GetAdmins.handler != nil { 243 return api.mock.GetAdmins.handler(ctx, req) 244 } 245 return nil, errors.Errorf("unhandled pachd mock auth.GetAdmins") 246 } 247 func (api *authServerAPI) ModifyAdmins(ctx context.Context, req *auth.ModifyAdminsRequest) (*auth.ModifyAdminsResponse, error) { 248 if api.mock.ModifyAdmins.handler != nil { 249 return api.mock.ModifyAdmins.handler(ctx, req) 250 } 251 return nil, errors.Errorf("unhandled pachd mock auth.ModifyAdmins") 252 } 253 func (api *authServerAPI) GetClusterRoleBindings(ctx context.Context, req *auth.GetClusterRoleBindingsRequest) (*auth.GetClusterRoleBindingsResponse, error) { 254 if api.mock.GetClusterRoleBindings.handler != nil { 255 return api.mock.GetClusterRoleBindings.handler(ctx, req) 256 } 257 return nil, errors.Errorf("unhandled pachd mock auth.GetClusterRoleBindings") 258 } 259 func (api *authServerAPI) ModifyClusterRoleBinding(ctx context.Context, req *auth.ModifyClusterRoleBindingRequest) (*auth.ModifyClusterRoleBindingResponse, error) { 260 if api.mock.ModifyClusterRoleBinding.handler != nil { 261 return api.mock.ModifyClusterRoleBinding.handler(ctx, req) 262 } 263 return nil, errors.Errorf("unhandled pachd mock auth.ModifyClusterRoleBinding") 264 } 265 func (api *authServerAPI) Authenticate(ctx context.Context, req *auth.AuthenticateRequest) (*auth.AuthenticateResponse, error) { 266 if api.mock.Authenticate.handler != nil { 267 return api.mock.Authenticate.handler(ctx, req) 268 } 269 return nil, errors.Errorf("unhandled pachd mock auth.Authenticate") 270 } 271 func (api *authServerAPI) Authorize(ctx context.Context, req *auth.AuthorizeRequest) (*auth.AuthorizeResponse, error) { 272 if api.mock.Authorize.handler != nil { 273 return api.mock.Authorize.handler(ctx, req) 274 } 275 return nil, errors.Errorf("unhandled pachd mock auth.Authorize") 276 } 277 func (api *authServerAPI) WhoAmI(ctx context.Context, req *auth.WhoAmIRequest) (*auth.WhoAmIResponse, error) { 278 if api.mock.WhoAmI.handler != nil { 279 return api.mock.WhoAmI.handler(ctx, req) 280 } 281 return nil, errors.Errorf("unhandled pachd mock auth.WhoAmI") 282 } 283 func (api *authServerAPI) GetScope(ctx context.Context, req *auth.GetScopeRequest) (*auth.GetScopeResponse, error) { 284 if api.mock.GetScope.handler != nil { 285 return api.mock.GetScope.handler(ctx, req) 286 } 287 return nil, errors.Errorf("unhandled pachd mock auth.GetScope") 288 } 289 func (api *authServerAPI) SetScope(ctx context.Context, req *auth.SetScopeRequest) (*auth.SetScopeResponse, error) { 290 if api.mock.SetScope.handler != nil { 291 return api.mock.SetScope.handler(ctx, req) 292 } 293 return nil, errors.Errorf("unhandled pachd mock auth.SetScope") 294 } 295 func (api *authServerAPI) GetACL(ctx context.Context, req *auth.GetACLRequest) (*auth.GetACLResponse, error) { 296 if api.mock.GetACL.handler != nil { 297 return api.mock.GetACL.handler(ctx, req) 298 } 299 return nil, errors.Errorf("unhandled pachd mock auth.GetACL") 300 } 301 func (api *authServerAPI) SetACL(ctx context.Context, req *auth.SetACLRequest) (*auth.SetACLResponse, error) { 302 if api.mock.SetACL.handler != nil { 303 return api.mock.SetACL.handler(ctx, req) 304 } 305 return nil, errors.Errorf("unhandled pachd mock auth.SetACL") 306 } 307 func (api *authServerAPI) GetOIDCLogin(ctx context.Context, req *auth.GetOIDCLoginRequest) (*auth.GetOIDCLoginResponse, error) { 308 if api.mock.GetOIDCLogin.handler != nil { 309 return api.mock.GetOIDCLogin.handler(ctx, req) 310 } 311 return nil, errors.Errorf("unhandled pachd mock auth.GetOIDCLogin") 312 } 313 func (api *authServerAPI) GetAuthToken(ctx context.Context, req *auth.GetAuthTokenRequest) (*auth.GetAuthTokenResponse, error) { 314 if api.mock.GetAuthToken.handler != nil { 315 return api.mock.GetAuthToken.handler(ctx, req) 316 } 317 return nil, errors.Errorf("unhandled pachd mock auth.GetAuthToken") 318 } 319 func (api *authServerAPI) ExtendAuthToken(ctx context.Context, req *auth.ExtendAuthTokenRequest) (*auth.ExtendAuthTokenResponse, error) { 320 if api.mock.ExtendAuthToken.handler != nil { 321 return api.mock.ExtendAuthToken.handler(ctx, req) 322 } 323 return nil, errors.Errorf("unhandled pachd mock auth.ExtendAuthToken") 324 } 325 func (api *authServerAPI) RevokeAuthToken(ctx context.Context, req *auth.RevokeAuthTokenRequest) (*auth.RevokeAuthTokenResponse, error) { 326 if api.mock.RevokeAuthToken.handler != nil { 327 return api.mock.RevokeAuthToken.handler(ctx, req) 328 } 329 return nil, errors.Errorf("unhandled pachd mock auth.RevokeAuthToken") 330 } 331 func (api *authServerAPI) SetGroupsForUser(ctx context.Context, req *auth.SetGroupsForUserRequest) (*auth.SetGroupsForUserResponse, error) { 332 if api.mock.SetGroupsForUser.handler != nil { 333 return api.mock.SetGroupsForUser.handler(ctx, req) 334 } 335 return nil, errors.Errorf("unhandled pachd mock auth.SetGroupsForUser") 336 } 337 func (api *authServerAPI) ModifyMembers(ctx context.Context, req *auth.ModifyMembersRequest) (*auth.ModifyMembersResponse, error) { 338 if api.mock.ModifyMembers.handler != nil { 339 return api.mock.ModifyMembers.handler(ctx, req) 340 } 341 return nil, errors.Errorf("unhandled pachd mock auth.ModifyMembers") 342 } 343 func (api *authServerAPI) GetGroups(ctx context.Context, req *auth.GetGroupsRequest) (*auth.GetGroupsResponse, error) { 344 if api.mock.GetGroups.handler != nil { 345 return api.mock.GetGroups.handler(ctx, req) 346 } 347 return nil, errors.Errorf("unhandled pachd mock auth.GetGroups") 348 } 349 func (api *authServerAPI) GetUsers(ctx context.Context, req *auth.GetUsersRequest) (*auth.GetUsersResponse, error) { 350 if api.mock.GetUsers.handler != nil { 351 return api.mock.GetUsers.handler(ctx, req) 352 } 353 return nil, errors.Errorf("unhandled pachd mock auth.GetUsers") 354 } 355 func (api *authServerAPI) GetOneTimePassword(ctx context.Context, req *auth.GetOneTimePasswordRequest) (*auth.GetOneTimePasswordResponse, error) { 356 if api.mock.GetOneTimePassword.handler != nil { 357 return api.mock.GetOneTimePassword.handler(ctx, req) 358 } 359 return nil, errors.Errorf("unhandled pachd mock auth.GetOneTimePassword") 360 } 361 362 func (api *authServerAPI) ExtractAuthTokens(ctx context.Context, req *auth.ExtractAuthTokensRequest) (*auth.ExtractAuthTokensResponse, error) { 363 if api.mock.ExtractAuthTokens.handler != nil { 364 return api.mock.ExtractAuthTokens.handler(ctx, req) 365 } 366 return nil, errors.Errorf("unhandled pachd mock auth.ExtractAuthTokens") 367 } 368 369 func (api *authServerAPI) RestoreAuthToken(ctx context.Context, req *auth.RestoreAuthTokenRequest) (*auth.RestoreAuthTokenResponse, error) { 370 if api.mock.RestoreAuthToken.handler != nil { 371 return api.mock.RestoreAuthToken.handler(ctx, req) 372 } 373 return nil, errors.Errorf("unhandled pachd mock auth.RestoreAuthToken") 374 } 375 376 /* Enterprise Server Mocks */ 377 378 type activateEnterpriseFunc func(context.Context, *enterprise.ActivateRequest) (*enterprise.ActivateResponse, error) 379 type getStateFunc func(context.Context, *enterprise.GetStateRequest) (*enterprise.GetStateResponse, error) 380 type getActivationCodeFunc func(context.Context, *enterprise.GetActivationCodeRequest) (*enterprise.GetActivationCodeResponse, error) 381 type deactivateEnterpriseFunc func(context.Context, *enterprise.DeactivateRequest) (*enterprise.DeactivateResponse, error) 382 383 type mockActivateEnterprise struct{ handler activateEnterpriseFunc } 384 type mockGetState struct{ handler getStateFunc } 385 type mockGetActivationCode struct{ handler getActivationCodeFunc } 386 type mockDeactivateEnterprise struct{ handler deactivateEnterpriseFunc } 387 388 func (mock *mockActivateEnterprise) Use(cb activateEnterpriseFunc) { mock.handler = cb } 389 func (mock *mockGetState) Use(cb getStateFunc) { mock.handler = cb } 390 func (mock *mockGetActivationCode) Use(cb getActivationCodeFunc) { mock.handler = cb } 391 func (mock *mockDeactivateEnterprise) Use(cb deactivateEnterpriseFunc) { mock.handler = cb } 392 393 type enterpriseServerAPI struct { 394 mock *mockEnterpriseServer 395 } 396 397 type mockEnterpriseServer struct { 398 api enterpriseServerAPI 399 Activate mockActivateEnterprise 400 GetState mockGetState 401 GetActivationCode mockGetActivationCode 402 Deactivate mockDeactivateEnterprise 403 } 404 405 func (api *enterpriseServerAPI) Activate(ctx context.Context, req *enterprise.ActivateRequest) (*enterprise.ActivateResponse, error) { 406 if api.mock.Activate.handler != nil { 407 return api.mock.Activate.handler(ctx, req) 408 } 409 return nil, errors.Errorf("unhandled pachd mock enterprise.Activate") 410 } 411 func (api *enterpriseServerAPI) GetState(ctx context.Context, req *enterprise.GetStateRequest) (*enterprise.GetStateResponse, error) { 412 if api.mock.GetState.handler != nil { 413 return api.mock.GetState.handler(ctx, req) 414 } 415 return nil, errors.Errorf("unhandled pachd mock enterprise.GetState") 416 } 417 func (api *enterpriseServerAPI) GetActivationCode(ctx context.Context, req *enterprise.GetActivationCodeRequest) (*enterprise.GetActivationCodeResponse, error) { 418 if api.mock.GetActivationCode.handler != nil { 419 return api.mock.GetActivationCode.handler(ctx, req) 420 } 421 return nil, errors.Errorf("unhandled pachd mock enterprise.GetActivationCode") 422 } 423 func (api *enterpriseServerAPI) Deactivate(ctx context.Context, req *enterprise.DeactivateRequest) (*enterprise.DeactivateResponse, error) { 424 if api.mock.Deactivate.handler != nil { 425 return api.mock.Deactivate.handler(ctx, req) 426 } 427 return nil, errors.Errorf("unhandled pachd mock enterprise.Deactivate") 428 } 429 430 /* PFS Server Mocks */ 431 432 type createRepoFunc func(context.Context, *pfs.CreateRepoRequest) (*types.Empty, error) 433 type inspectRepoFunc func(context.Context, *pfs.InspectRepoRequest) (*pfs.RepoInfo, error) 434 type listRepoFunc func(context.Context, *pfs.ListRepoRequest) (*pfs.ListRepoResponse, error) 435 type deleteRepoFunc func(context.Context, *pfs.DeleteRepoRequest) (*types.Empty, error) 436 type startCommitFunc func(context.Context, *pfs.StartCommitRequest) (*pfs.Commit, error) 437 type finishCommitFunc func(context.Context, *pfs.FinishCommitRequest) (*types.Empty, error) 438 type inspectCommitFunc func(context.Context, *pfs.InspectCommitRequest) (*pfs.CommitInfo, error) 439 type listCommitFunc func(context.Context, *pfs.ListCommitRequest) (*pfs.CommitInfos, error) 440 type listCommitStreamFunc func(*pfs.ListCommitRequest, pfs.API_ListCommitStreamServer) error 441 type deleteCommitFunc func(context.Context, *pfs.DeleteCommitRequest) (*types.Empty, error) 442 type flushCommitFunc func(*pfs.FlushCommitRequest, pfs.API_FlushCommitServer) error 443 type subscribeCommitFunc func(*pfs.SubscribeCommitRequest, pfs.API_SubscribeCommitServer) error 444 type buildCommitFunc func(context.Context, *pfs.BuildCommitRequest) (*pfs.Commit, error) 445 type createBranchFunc func(context.Context, *pfs.CreateBranchRequest) (*types.Empty, error) 446 type inspectBranchFunc func(context.Context, *pfs.InspectBranchRequest) (*pfs.BranchInfo, error) 447 type listBranchFunc func(context.Context, *pfs.ListBranchRequest) (*pfs.BranchInfos, error) 448 type deleteBranchFunc func(context.Context, *pfs.DeleteBranchRequest) (*types.Empty, error) 449 type putFileFunc func(pfs.API_PutFileServer) error 450 type copyFileFunc func(context.Context, *pfs.CopyFileRequest) (*types.Empty, error) 451 type getFileFunc func(*pfs.GetFileRequest, pfs.API_GetFileServer) error 452 type inspectFileFunc func(context.Context, *pfs.InspectFileRequest) (*pfs.FileInfo, error) 453 type listFileFunc func(context.Context, *pfs.ListFileRequest) (*pfs.FileInfos, error) 454 type listFileStreamFunc func(*pfs.ListFileRequest, pfs.API_ListFileStreamServer) error 455 type walkFileFunc func(*pfs.WalkFileRequest, pfs.API_WalkFileServer) error 456 type globFileFunc func(context.Context, *pfs.GlobFileRequest) (*pfs.FileInfos, error) 457 type globFileStreamFunc func(*pfs.GlobFileRequest, pfs.API_GlobFileStreamServer) error 458 type diffFileFunc func(context.Context, *pfs.DiffFileRequest) (*pfs.DiffFileResponse, error) 459 type deleteFileFunc func(context.Context, *pfs.DeleteFileRequest) (*types.Empty, error) 460 type deleteAllPFSFunc func(context.Context, *types.Empty) (*types.Empty, error) 461 type fsckFunc func(*pfs.FsckRequest, pfs.API_FsckServer) error 462 type fileOperationFuncV2 func(pfs.API_FileOperationV2Server) error 463 type getTarFuncV2 func(*pfs.GetTarRequestV2, pfs.API_GetTarV2Server) error 464 type diffFileV2Func func(*pfs.DiffFileRequest, pfs.API_DiffFileV2Server) error 465 type createTmpFileSetFunc func(pfs.API_CreateTmpFileSetServer) error 466 type renewTmpFileSetFunc func(context.Context, *pfs.RenewTmpFileSetRequest) (*types.Empty, error) 467 type clearCommitV2Func func(context.Context, *pfs.ClearCommitRequestV2) (*types.Empty, error) 468 469 type mockCreateRepo struct{ handler createRepoFunc } 470 type mockInspectRepo struct{ handler inspectRepoFunc } 471 type mockListRepo struct{ handler listRepoFunc } 472 type mockDeleteRepo struct{ handler deleteRepoFunc } 473 type mockStartCommit struct{ handler startCommitFunc } 474 type mockFinishCommit struct{ handler finishCommitFunc } 475 type mockInspectCommit struct{ handler inspectCommitFunc } 476 type mockListCommit struct{ handler listCommitFunc } 477 type mockListCommitStream struct{ handler listCommitStreamFunc } 478 type mockDeleteCommit struct{ handler deleteCommitFunc } 479 type mockFlushCommit struct{ handler flushCommitFunc } 480 type mockSubscribeCommit struct{ handler subscribeCommitFunc } 481 type mockBuildCommit struct{ handler buildCommitFunc } 482 type mockCreateBranch struct{ handler createBranchFunc } 483 type mockInspectBranch struct{ handler inspectBranchFunc } 484 type mockListBranch struct{ handler listBranchFunc } 485 type mockDeleteBranch struct{ handler deleteBranchFunc } 486 type mockPutFile struct{ handler putFileFunc } 487 type mockCopyFile struct{ handler copyFileFunc } 488 type mockGetFile struct{ handler getFileFunc } 489 type mockInspectFile struct{ handler inspectFileFunc } 490 type mockListFile struct{ handler listFileFunc } 491 type mockListFileStream struct{ handler listFileStreamFunc } 492 type mockWalkFile struct{ handler walkFileFunc } 493 type mockGlobFile struct{ handler globFileFunc } 494 type mockGlobFileStream struct{ handler globFileStreamFunc } 495 type mockDiffFile struct{ handler diffFileFunc } 496 type mockDeleteFile struct{ handler deleteFileFunc } 497 type mockDeleteAllPFS struct{ handler deleteAllPFSFunc } 498 type mockFsck struct{ handler fsckFunc } 499 type mockFileOperationV2 struct{ handler fileOperationFuncV2 } 500 type mockGetTarV2 struct{ handler getTarFuncV2 } 501 type mockDiffFileV2 struct{ handler diffFileV2Func } 502 type mockClearCommitV2 struct{ handler clearCommitV2Func } 503 type mockCreateTmpFileSet struct{ handler createTmpFileSetFunc } 504 type mockRenewTmpFileSet struct{ handler renewTmpFileSetFunc } 505 506 func (mock *mockCreateRepo) Use(cb createRepoFunc) { mock.handler = cb } 507 func (mock *mockInspectRepo) Use(cb inspectRepoFunc) { mock.handler = cb } 508 func (mock *mockListRepo) Use(cb listRepoFunc) { mock.handler = cb } 509 func (mock *mockDeleteRepo) Use(cb deleteRepoFunc) { mock.handler = cb } 510 func (mock *mockStartCommit) Use(cb startCommitFunc) { mock.handler = cb } 511 func (mock *mockFinishCommit) Use(cb finishCommitFunc) { mock.handler = cb } 512 func (mock *mockInspectCommit) Use(cb inspectCommitFunc) { mock.handler = cb } 513 func (mock *mockListCommit) Use(cb listCommitFunc) { mock.handler = cb } 514 func (mock *mockListCommitStream) Use(cb listCommitStreamFunc) { mock.handler = cb } 515 func (mock *mockDeleteCommit) Use(cb deleteCommitFunc) { mock.handler = cb } 516 func (mock *mockFlushCommit) Use(cb flushCommitFunc) { mock.handler = cb } 517 func (mock *mockSubscribeCommit) Use(cb subscribeCommitFunc) { mock.handler = cb } 518 func (mock *mockBuildCommit) Use(cb buildCommitFunc) { mock.handler = cb } 519 func (mock *mockCreateBranch) Use(cb createBranchFunc) { mock.handler = cb } 520 func (mock *mockInspectBranch) Use(cb inspectBranchFunc) { mock.handler = cb } 521 func (mock *mockListBranch) Use(cb listBranchFunc) { mock.handler = cb } 522 func (mock *mockDeleteBranch) Use(cb deleteBranchFunc) { mock.handler = cb } 523 func (mock *mockPutFile) Use(cb putFileFunc) { mock.handler = cb } 524 func (mock *mockCopyFile) Use(cb copyFileFunc) { mock.handler = cb } 525 func (mock *mockGetFile) Use(cb getFileFunc) { mock.handler = cb } 526 func (mock *mockInspectFile) Use(cb inspectFileFunc) { mock.handler = cb } 527 func (mock *mockListFile) Use(cb listFileFunc) { mock.handler = cb } 528 func (mock *mockListFileStream) Use(cb listFileStreamFunc) { mock.handler = cb } 529 func (mock *mockWalkFile) Use(cb walkFileFunc) { mock.handler = cb } 530 func (mock *mockGlobFile) Use(cb globFileFunc) { mock.handler = cb } 531 func (mock *mockGlobFileStream) Use(cb globFileStreamFunc) { mock.handler = cb } 532 func (mock *mockDiffFile) Use(cb diffFileFunc) { mock.handler = cb } 533 func (mock *mockDeleteFile) Use(cb deleteFileFunc) { mock.handler = cb } 534 func (mock *mockDeleteAllPFS) Use(cb deleteAllPFSFunc) { mock.handler = cb } 535 func (mock *mockFsck) Use(cb fsckFunc) { mock.handler = cb } 536 func (mock *mockFileOperationV2) Use(cb fileOperationFuncV2) { mock.handler = cb } 537 func (mock *mockGetTarV2) Use(cb getTarFuncV2) { mock.handler = cb } 538 func (mock *mockDiffFileV2) Use(cb diffFileV2Func) { mock.handler = cb } 539 func (mock *mockClearCommitV2) Use(cb clearCommitV2Func) { mock.handler = cb } 540 func (mock *mockCreateTmpFileSet) Use(cb createTmpFileSetFunc) { mock.handler = cb } 541 func (mock *mockRenewTmpFileSet) Use(cb renewTmpFileSetFunc) { mock.handler = cb } 542 543 type pfsServerAPI struct { 544 mock *mockPFSServer 545 } 546 547 type mockPFSServer struct { 548 api pfsServerAPI 549 CreateRepo mockCreateRepo 550 InspectRepo mockInspectRepo 551 ListRepo mockListRepo 552 DeleteRepo mockDeleteRepo 553 StartCommit mockStartCommit 554 FinishCommit mockFinishCommit 555 InspectCommit mockInspectCommit 556 ListCommit mockListCommit 557 ListCommitStream mockListCommitStream 558 DeleteCommit mockDeleteCommit 559 FlushCommit mockFlushCommit 560 SubscribeCommit mockSubscribeCommit 561 BuildCommit mockBuildCommit 562 CreateBranch mockCreateBranch 563 InspectBranch mockInspectBranch 564 ListBranch mockListBranch 565 DeleteBranch mockDeleteBranch 566 PutFile mockPutFile 567 CopyFile mockCopyFile 568 GetFile mockGetFile 569 InspectFile mockInspectFile 570 ListFile mockListFile 571 ListFileStream mockListFileStream 572 WalkFile mockWalkFile 573 GlobFile mockGlobFile 574 GlobFileStream mockGlobFileStream 575 DiffFile mockDiffFile 576 DeleteFile mockDeleteFile 577 DeleteAll mockDeleteAllPFS 578 Fsck mockFsck 579 FileOperationV2 mockFileOperationV2 580 GetTarV2 mockGetTarV2 581 DiffFileV2 mockDiffFileV2 582 ClearCommitV2 mockClearCommitV2 583 CreateTmpFileSet mockCreateTmpFileSet 584 RenewTmpFileSet mockRenewTmpFileSet 585 } 586 587 func (api *pfsServerAPI) CreateRepo(ctx context.Context, req *pfs.CreateRepoRequest) (*types.Empty, error) { 588 if api.mock.CreateRepo.handler != nil { 589 return api.mock.CreateRepo.handler(ctx, req) 590 } 591 return nil, errors.Errorf("unhandled pachd mock pfs.CreateRepo") 592 } 593 func (api *pfsServerAPI) InspectRepo(ctx context.Context, req *pfs.InspectRepoRequest) (*pfs.RepoInfo, error) { 594 if api.mock.InspectRepo.handler != nil { 595 return api.mock.InspectRepo.handler(ctx, req) 596 } 597 return nil, errors.Errorf("unhandled pachd mock pfs.InspectRepo") 598 } 599 func (api *pfsServerAPI) ListRepo(ctx context.Context, req *pfs.ListRepoRequest) (*pfs.ListRepoResponse, error) { 600 if api.mock.ListRepo.handler != nil { 601 return api.mock.ListRepo.handler(ctx, req) 602 } 603 return nil, errors.Errorf("unhandled pachd mock pfs.ListRepo") 604 } 605 func (api *pfsServerAPI) DeleteRepo(ctx context.Context, req *pfs.DeleteRepoRequest) (*types.Empty, error) { 606 if api.mock.DeleteRepo.handler != nil { 607 return api.mock.DeleteRepo.handler(ctx, req) 608 } 609 return nil, errors.Errorf("unhandled pachd mock pfs.DeleteRepo") 610 } 611 func (api *pfsServerAPI) StartCommit(ctx context.Context, req *pfs.StartCommitRequest) (*pfs.Commit, error) { 612 if api.mock.StartCommit.handler != nil { 613 return api.mock.StartCommit.handler(ctx, req) 614 } 615 return nil, errors.Errorf("unhandled pachd mock pfs.StartCommit") 616 } 617 func (api *pfsServerAPI) FinishCommit(ctx context.Context, req *pfs.FinishCommitRequest) (*types.Empty, error) { 618 if api.mock.FinishCommit.handler != nil { 619 return api.mock.FinishCommit.handler(ctx, req) 620 } 621 return nil, errors.Errorf("unhandled pachd mock pfs.FinishCommit") 622 } 623 func (api *pfsServerAPI) InspectCommit(ctx context.Context, req *pfs.InspectCommitRequest) (*pfs.CommitInfo, error) { 624 if api.mock.InspectCommit.handler != nil { 625 return api.mock.InspectCommit.handler(ctx, req) 626 } 627 return nil, errors.Errorf("unhandled pachd mock pfs.InspectCommit") 628 } 629 func (api *pfsServerAPI) ListCommit(ctx context.Context, req *pfs.ListCommitRequest) (*pfs.CommitInfos, error) { 630 if api.mock.ListCommit.handler != nil { 631 return api.mock.ListCommit.handler(ctx, req) 632 } 633 return nil, errors.Errorf("unhandled pachd mock pfs.ListCommit") 634 } 635 func (api *pfsServerAPI) ListCommitStream(req *pfs.ListCommitRequest, serv pfs.API_ListCommitStreamServer) error { 636 if api.mock.ListCommitStream.handler != nil { 637 return api.mock.ListCommitStream.handler(req, serv) 638 } 639 return errors.Errorf("unhandled pachd mock pfs.ListCommitStream") 640 } 641 func (api *pfsServerAPI) DeleteCommit(ctx context.Context, req *pfs.DeleteCommitRequest) (*types.Empty, error) { 642 if api.mock.DeleteCommit.handler != nil { 643 return api.mock.DeleteCommit.handler(ctx, req) 644 } 645 return nil, errors.Errorf("unhandled pachd mock pfs.DeleteCommit") 646 } 647 func (api *pfsServerAPI) FlushCommit(req *pfs.FlushCommitRequest, serv pfs.API_FlushCommitServer) error { 648 if api.mock.FlushCommit.handler != nil { 649 return api.mock.FlushCommit.handler(req, serv) 650 } 651 return errors.Errorf("unhandled pachd mock pfs.FlushCommit") 652 } 653 func (api *pfsServerAPI) SubscribeCommit(req *pfs.SubscribeCommitRequest, serv pfs.API_SubscribeCommitServer) error { 654 if api.mock.SubscribeCommit.handler != nil { 655 return api.mock.SubscribeCommit.handler(req, serv) 656 } 657 return errors.Errorf("unhandled pachd mock pfs.SubscribeCommit") 658 } 659 func (api *pfsServerAPI) BuildCommit(ctx context.Context, req *pfs.BuildCommitRequest) (*pfs.Commit, error) { 660 if api.mock.BuildCommit.handler != nil { 661 return api.mock.BuildCommit.handler(ctx, req) 662 } 663 return nil, errors.Errorf("unhandled pachd mock pfs.BuildCommit") 664 } 665 func (api *pfsServerAPI) CreateBranch(ctx context.Context, req *pfs.CreateBranchRequest) (*types.Empty, error) { 666 if api.mock.CreateBranch.handler != nil { 667 return api.mock.CreateBranch.handler(ctx, req) 668 } 669 return nil, errors.Errorf("unhandled pachd mock pfs.CreateBranch") 670 } 671 func (api *pfsServerAPI) InspectBranch(ctx context.Context, req *pfs.InspectBranchRequest) (*pfs.BranchInfo, error) { 672 if api.mock.InspectBranch.handler != nil { 673 return api.mock.InspectBranch.handler(ctx, req) 674 } 675 return nil, errors.Errorf("unhandled pachd mock pfs.InspectBranch") 676 } 677 func (api *pfsServerAPI) ListBranch(ctx context.Context, req *pfs.ListBranchRequest) (*pfs.BranchInfos, error) { 678 if api.mock.ListBranch.handler != nil { 679 return api.mock.ListBranch.handler(ctx, req) 680 } 681 return nil, errors.Errorf("unhandled pachd mock pfs.ListBranch") 682 } 683 func (api *pfsServerAPI) DeleteBranch(ctx context.Context, req *pfs.DeleteBranchRequest) (*types.Empty, error) { 684 if api.mock.DeleteBranch.handler != nil { 685 return api.mock.DeleteBranch.handler(ctx, req) 686 } 687 return nil, errors.Errorf("unhandled pachd mock pfs.DeleteBranch") 688 } 689 func (api *pfsServerAPI) PutFile(serv pfs.API_PutFileServer) error { 690 if api.mock.PutFile.handler != nil { 691 return api.mock.PutFile.handler(serv) 692 } 693 return errors.Errorf("unhandled pachd mock pfs.PutFile") 694 } 695 func (api *pfsServerAPI) CopyFile(ctx context.Context, req *pfs.CopyFileRequest) (*types.Empty, error) { 696 if api.mock.CopyFile.handler != nil { 697 return api.mock.CopyFile.handler(ctx, req) 698 } 699 return nil, errors.Errorf("unhandled pachd mock pfs.CopyFile") 700 } 701 func (api *pfsServerAPI) GetFile(req *pfs.GetFileRequest, serv pfs.API_GetFileServer) error { 702 if api.mock.GetFile.handler != nil { 703 return api.mock.GetFile.handler(req, serv) 704 } 705 return errors.Errorf("unhandled pachd mock pfs.GetFile") 706 } 707 func (api *pfsServerAPI) InspectFile(ctx context.Context, req *pfs.InspectFileRequest) (*pfs.FileInfo, error) { 708 if api.mock.InspectFile.handler != nil { 709 return api.mock.InspectFile.handler(ctx, req) 710 } 711 return nil, errors.Errorf("unhandled pachd mock pfs.InspectFile") 712 } 713 func (api *pfsServerAPI) ListFile(ctx context.Context, req *pfs.ListFileRequest) (*pfs.FileInfos, error) { 714 if api.mock.ListFile.handler != nil { 715 return api.mock.ListFile.handler(ctx, req) 716 } 717 return nil, errors.Errorf("unhandled pachd mock pfs.ListFile") 718 } 719 func (api *pfsServerAPI) ListFileStream(req *pfs.ListFileRequest, serv pfs.API_ListFileStreamServer) error { 720 if api.mock.ListFileStream.handler != nil { 721 return api.mock.ListFileStream.handler(req, serv) 722 } 723 return errors.Errorf("unhandled pachd mock pfs.ListFileStream") 724 } 725 func (api *pfsServerAPI) WalkFile(req *pfs.WalkFileRequest, serv pfs.API_WalkFileServer) error { 726 if api.mock.WalkFile.handler != nil { 727 return api.mock.WalkFile.handler(req, serv) 728 } 729 return errors.Errorf("unhandled pachd mock pfs.WalkFile") 730 } 731 func (api *pfsServerAPI) GlobFile(ctx context.Context, req *pfs.GlobFileRequest) (*pfs.FileInfos, error) { 732 if api.mock.GlobFile.handler != nil { 733 return api.mock.GlobFile.handler(ctx, req) 734 } 735 return nil, errors.Errorf("unhandled pachd mock pfs.GlobFile") 736 } 737 func (api *pfsServerAPI) GlobFileStream(req *pfs.GlobFileRequest, serv pfs.API_GlobFileStreamServer) error { 738 if api.mock.GlobFileStream.handler != nil { 739 return api.mock.GlobFileStream.handler(req, serv) 740 } 741 return errors.Errorf("unhandled pachd mock pfs.GlobFileStream") 742 } 743 func (api *pfsServerAPI) DiffFile(ctx context.Context, req *pfs.DiffFileRequest) (*pfs.DiffFileResponse, error) { 744 if api.mock.DiffFile.handler != nil { 745 return api.mock.DiffFile.handler(ctx, req) 746 } 747 return nil, errors.Errorf("unhandled pachd mock pfs.DiffFile") 748 } 749 func (api *pfsServerAPI) DeleteFile(ctx context.Context, req *pfs.DeleteFileRequest) (*types.Empty, error) { 750 if api.mock.DeleteFile.handler != nil { 751 return api.mock.DeleteFile.handler(ctx, req) 752 } 753 return nil, errors.Errorf("unhandled pachd mock pfs.DeleteFile") 754 } 755 func (api *pfsServerAPI) DeleteAll(ctx context.Context, req *types.Empty) (*types.Empty, error) { 756 if api.mock.DeleteAll.handler != nil { 757 return api.mock.DeleteAll.handler(ctx, req) 758 } 759 return nil, errors.Errorf("unhandled pachd mock pfs.DeleteAll") 760 } 761 func (api *pfsServerAPI) Fsck(req *pfs.FsckRequest, serv pfs.API_FsckServer) error { 762 if api.mock.Fsck.handler != nil { 763 return api.mock.Fsck.handler(req, serv) 764 } 765 return errors.Errorf("unhandled pachd mock pfs.Fsck") 766 } 767 func (api *pfsServerAPI) FileOperationV2(serv pfs.API_FileOperationV2Server) error { 768 if api.mock.FileOperationV2.handler != nil { 769 return api.mock.FileOperationV2.handler(serv) 770 } 771 return errors.Errorf("unhandled pachd mock pfs.FileOperationV2") 772 } 773 func (api *pfsServerAPI) GetTarV2(req *pfs.GetTarRequestV2, serv pfs.API_GetTarV2Server) error { 774 if api.mock.GetTarV2.handler != nil { 775 return api.mock.GetTarV2.handler(req, serv) 776 } 777 return errors.Errorf("unhandled pachd mock pfs.GetTarV2") 778 } 779 func (api *pfsServerAPI) DiffFileV2(req *pfs.DiffFileRequest, serv pfs.API_DiffFileV2Server) error { 780 if api.mock.DiffFileV2.handler != nil { 781 return api.mock.DiffFileV2.handler(req, serv) 782 } 783 return errors.Errorf("unhandled pachd mock pfs.DiffFileV2") 784 } 785 func (api *pfsServerAPI) ClearCommitV2(ctx context.Context, req *pfs.ClearCommitRequestV2) (*types.Empty, error) { 786 if api.mock.ClearCommitV2.handler != nil { 787 return api.mock.ClearCommitV2.handler(ctx, req) 788 } 789 return nil, errors.Errorf("unhandled pachd mock pfs.ClearCommitV2") 790 } 791 func (api *pfsServerAPI) CreateTmpFileSet(srv pfs.API_CreateTmpFileSetServer) error { 792 if api.mock.CreateTmpFileSet.handler != nil { 793 return api.mock.CreateTmpFileSet.handler(srv) 794 } 795 return errors.Errorf("unhandled pachd mock pfs.CreateTmpFileSet") 796 } 797 func (api *pfsServerAPI) RenewTmpFileSet(ctx context.Context, req *pfs.RenewTmpFileSetRequest) (*types.Empty, error) { 798 if api.mock.RenewTmpFileSet.handler != nil { 799 return api.mock.RenewTmpFileSet.handler(ctx, req) 800 } 801 return nil, errors.Errorf("unhandled pachd mock pfs.RenewTmpFileSet") 802 } 803 804 /* PPS Server Mocks */ 805 806 type createJobFunc func(context.Context, *pps.CreateJobRequest) (*pps.Job, error) 807 type inspectJobFunc func(context.Context, *pps.InspectJobRequest) (*pps.JobInfo, error) 808 type listJobFunc func(context.Context, *pps.ListJobRequest) (*pps.JobInfos, error) 809 type listJobStreamFunc func(*pps.ListJobRequest, pps.API_ListJobStreamServer) error 810 type flushJobFunc func(*pps.FlushJobRequest, pps.API_FlushJobServer) error 811 type deleteJobFunc func(context.Context, *pps.DeleteJobRequest) (*types.Empty, error) 812 type stopJobFunc func(context.Context, *pps.StopJobRequest) (*types.Empty, error) 813 type updateJobStateFunc func(context.Context, *pps.UpdateJobStateRequest) (*types.Empty, error) 814 type inspectDatumFunc func(context.Context, *pps.InspectDatumRequest) (*pps.DatumInfo, error) 815 type listDatumFunc func(context.Context, *pps.ListDatumRequest) (*pps.ListDatumResponse, error) 816 type listDatumStreamFunc func(*pps.ListDatumRequest, pps.API_ListDatumStreamServer) error 817 type restartDatumFunc func(context.Context, *pps.RestartDatumRequest) (*types.Empty, error) 818 type createPipelineFunc func(context.Context, *pps.CreatePipelineRequest) (*types.Empty, error) 819 type inspectPipelineFunc func(context.Context, *pps.InspectPipelineRequest) (*pps.PipelineInfo, error) 820 type listPipelineFunc func(context.Context, *pps.ListPipelineRequest) (*pps.PipelineInfos, error) 821 type deletePipelineFunc func(context.Context, *pps.DeletePipelineRequest) (*types.Empty, error) 822 type startPipelineFunc func(context.Context, *pps.StartPipelineRequest) (*types.Empty, error) 823 type stopPipelineFunc func(context.Context, *pps.StopPipelineRequest) (*types.Empty, error) 824 type runPipelineFunc func(context.Context, *pps.RunPipelineRequest) (*types.Empty, error) 825 type runCronFunc func(context.Context, *pps.RunCronRequest) (*types.Empty, error) 826 type createSecretFunc func(context.Context, *pps.CreateSecretRequest) (*types.Empty, error) 827 type deleteSecretFunc func(context.Context, *pps.DeleteSecretRequest) (*types.Empty, error) 828 type inspectSecretFunc func(context.Context, *pps.InspectSecretRequest) (*pps.SecretInfo, error) 829 type listSecretFunc func(context.Context, *types.Empty) (*pps.SecretInfos, error) 830 type deleteAllPPSFunc func(context.Context, *types.Empty) (*types.Empty, error) 831 type getLogsFunc func(*pps.GetLogsRequest, pps.API_GetLogsServer) error 832 type garbageCollectFunc func(context.Context, *pps.GarbageCollectRequest) (*pps.GarbageCollectResponse, error) 833 type activateAuthPPSFunc func(context.Context, *pps.ActivateAuthRequest) (*pps.ActivateAuthResponse, error) 834 835 type mockCreateJob struct{ handler createJobFunc } 836 type mockInspectJob struct{ handler inspectJobFunc } 837 type mockListJob struct{ handler listJobFunc } 838 type mockListJobStream struct{ handler listJobStreamFunc } 839 type mockFlushJob struct{ handler flushJobFunc } 840 type mockDeleteJob struct{ handler deleteJobFunc } 841 type mockStopJob struct{ handler stopJobFunc } 842 type mockUpdateJobState struct{ handler updateJobStateFunc } 843 type mockInspectDatum struct{ handler inspectDatumFunc } 844 type mockListDatum struct{ handler listDatumFunc } 845 type mockListDatumStream struct{ handler listDatumStreamFunc } 846 type mockRestartDatum struct{ handler restartDatumFunc } 847 type mockCreatePipeline struct{ handler createPipelineFunc } 848 type mockInspectPipeline struct{ handler inspectPipelineFunc } 849 type mockListPipeline struct{ handler listPipelineFunc } 850 type mockDeletePipeline struct{ handler deletePipelineFunc } 851 type mockStartPipeline struct{ handler startPipelineFunc } 852 type mockStopPipeline struct{ handler stopPipelineFunc } 853 type mockRunPipeline struct{ handler runPipelineFunc } 854 type mockRunCron struct{ handler runCronFunc } 855 type mockCreateSecret struct{ handler createSecretFunc } 856 type mockDeleteSecret struct{ handler deleteSecretFunc } 857 type mockInspectSecret struct{ handler inspectSecretFunc } 858 type mockListSecret struct{ handler listSecretFunc } 859 type mockDeleteAllPPS struct{ handler deleteAllPPSFunc } 860 type mockGetLogs struct{ handler getLogsFunc } 861 type mockGarbageCollect struct{ handler garbageCollectFunc } 862 type mockActivateAuthPPS struct{ handler activateAuthPPSFunc } 863 864 func (mock *mockCreateJob) Use(cb createJobFunc) { mock.handler = cb } 865 func (mock *mockInspectJob) Use(cb inspectJobFunc) { mock.handler = cb } 866 func (mock *mockListJob) Use(cb listJobFunc) { mock.handler = cb } 867 func (mock *mockListJobStream) Use(cb listJobStreamFunc) { mock.handler = cb } 868 func (mock *mockFlushJob) Use(cb flushJobFunc) { mock.handler = cb } 869 func (mock *mockDeleteJob) Use(cb deleteJobFunc) { mock.handler = cb } 870 func (mock *mockStopJob) Use(cb stopJobFunc) { mock.handler = cb } 871 func (mock *mockUpdateJobState) Use(cb updateJobStateFunc) { mock.handler = cb } 872 func (mock *mockInspectDatum) Use(cb inspectDatumFunc) { mock.handler = cb } 873 func (mock *mockListDatum) Use(cb listDatumFunc) { mock.handler = cb } 874 func (mock *mockListDatumStream) Use(cb listDatumStreamFunc) { mock.handler = cb } 875 func (mock *mockRestartDatum) Use(cb restartDatumFunc) { mock.handler = cb } 876 func (mock *mockCreatePipeline) Use(cb createPipelineFunc) { mock.handler = cb } 877 func (mock *mockInspectPipeline) Use(cb inspectPipelineFunc) { mock.handler = cb } 878 func (mock *mockListPipeline) Use(cb listPipelineFunc) { mock.handler = cb } 879 func (mock *mockDeletePipeline) Use(cb deletePipelineFunc) { mock.handler = cb } 880 func (mock *mockStartPipeline) Use(cb startPipelineFunc) { mock.handler = cb } 881 func (mock *mockStopPipeline) Use(cb stopPipelineFunc) { mock.handler = cb } 882 func (mock *mockRunPipeline) Use(cb runPipelineFunc) { mock.handler = cb } 883 func (mock *mockRunCron) Use(cb runCronFunc) { mock.handler = cb } 884 func (mock *mockCreateSecret) Use(cb createSecretFunc) { mock.handler = cb } 885 func (mock *mockDeleteSecret) Use(cb deleteSecretFunc) { mock.handler = cb } 886 func (mock *mockInspectSecret) Use(cb inspectSecretFunc) { mock.handler = cb } 887 func (mock *mockListSecret) Use(cb listSecretFunc) { mock.handler = cb } 888 func (mock *mockDeleteAllPPS) Use(cb deleteAllPPSFunc) { mock.handler = cb } 889 func (mock *mockGetLogs) Use(cb getLogsFunc) { mock.handler = cb } 890 func (mock *mockGarbageCollect) Use(cb garbageCollectFunc) { mock.handler = cb } 891 func (mock *mockActivateAuthPPS) Use(cb activateAuthPPSFunc) { mock.handler = cb } 892 893 type ppsServerAPI struct { 894 mock *mockPPSServer 895 } 896 897 type mockPPSServer struct { 898 api ppsServerAPI 899 CreateJob mockCreateJob 900 InspectJob mockInspectJob 901 ListJob mockListJob 902 ListJobStream mockListJobStream 903 FlushJob mockFlushJob 904 DeleteJob mockDeleteJob 905 StopJob mockStopJob 906 UpdateJobState mockUpdateJobState 907 InspectDatum mockInspectDatum 908 ListDatum mockListDatum 909 ListDatumStream mockListDatumStream 910 RestartDatum mockRestartDatum 911 CreatePipeline mockCreatePipeline 912 InspectPipeline mockInspectPipeline 913 ListPipeline mockListPipeline 914 DeletePipeline mockDeletePipeline 915 StartPipeline mockStartPipeline 916 StopPipeline mockStopPipeline 917 RunPipeline mockRunPipeline 918 RunCron mockRunCron 919 CreateSecret mockCreateSecret 920 DeleteSecret mockDeleteSecret 921 InspectSecret mockInspectSecret 922 ListSecret mockListSecret 923 DeleteAll mockDeleteAllPPS 924 GetLogs mockGetLogs 925 GarbageCollect mockGarbageCollect 926 ActivateAuth mockActivateAuthPPS 927 } 928 929 func (api *ppsServerAPI) CreateJob(ctx context.Context, req *pps.CreateJobRequest) (*pps.Job, error) { 930 if api.mock.CreateJob.handler != nil { 931 return api.mock.CreateJob.handler(ctx, req) 932 } 933 return nil, errors.Errorf("unhandled pachd mock pps.CreateJob") 934 } 935 func (api *ppsServerAPI) InspectJob(ctx context.Context, req *pps.InspectJobRequest) (*pps.JobInfo, error) { 936 if api.mock.InspectJob.handler != nil { 937 return api.mock.InspectJob.handler(ctx, req) 938 } 939 return nil, errors.Errorf("unhandled pachd mock pps.InspectJob") 940 } 941 func (api *ppsServerAPI) ListJob(ctx context.Context, req *pps.ListJobRequest) (*pps.JobInfos, error) { 942 if api.mock.ListJob.handler != nil { 943 return api.mock.ListJob.handler(ctx, req) 944 } 945 return nil, errors.Errorf("unhandled pachd mock pps.ListJob") 946 } 947 func (api *ppsServerAPI) ListJobStream(req *pps.ListJobRequest, serv pps.API_ListJobStreamServer) error { 948 if api.mock.ListJobStream.handler != nil { 949 return api.mock.ListJobStream.handler(req, serv) 950 } 951 return errors.Errorf("unhandled pachd mock pps.ListJobStream") 952 } 953 func (api *ppsServerAPI) FlushJob(req *pps.FlushJobRequest, serv pps.API_FlushJobServer) error { 954 if api.mock.FlushJob.handler != nil { 955 return api.mock.FlushJob.handler(req, serv) 956 } 957 return errors.Errorf("unhandled pachd mock pps.FlushJob") 958 } 959 func (api *ppsServerAPI) DeleteJob(ctx context.Context, req *pps.DeleteJobRequest) (*types.Empty, error) { 960 if api.mock.DeleteJob.handler != nil { 961 return api.mock.DeleteJob.handler(ctx, req) 962 } 963 return nil, errors.Errorf("unhandled pachd mock pps.DeleteJob") 964 } 965 func (api *ppsServerAPI) UpdateJobState(ctx context.Context, req *pps.UpdateJobStateRequest) (*types.Empty, error) { 966 if api.mock.UpdateJobState.handler != nil { 967 return api.mock.UpdateJobState.handler(ctx, req) 968 } 969 return nil, errors.Errorf("unhandled pachd mock pps.UpdateJobState") 970 } 971 func (api *ppsServerAPI) StopJob(ctx context.Context, req *pps.StopJobRequest) (*types.Empty, error) { 972 if api.mock.StopJob.handler != nil { 973 return api.mock.StopJob.handler(ctx, req) 974 } 975 return nil, errors.Errorf("unhandled pachd mock pps.StopJob") 976 } 977 func (api *ppsServerAPI) InspectDatum(ctx context.Context, req *pps.InspectDatumRequest) (*pps.DatumInfo, error) { 978 if api.mock.InspectDatum.handler != nil { 979 return api.mock.InspectDatum.handler(ctx, req) 980 } 981 return nil, errors.Errorf("unhandled pachd mock pps.InspectDatum") 982 } 983 func (api *ppsServerAPI) ListDatum(ctx context.Context, req *pps.ListDatumRequest) (*pps.ListDatumResponse, error) { 984 if api.mock.ListDatum.handler != nil { 985 return api.mock.ListDatum.handler(ctx, req) 986 } 987 return nil, errors.Errorf("unhandled pachd mock pps.ListDatum") 988 } 989 func (api *ppsServerAPI) ListDatumStream(req *pps.ListDatumRequest, serv pps.API_ListDatumStreamServer) error { 990 if api.mock.ListDatumStream.handler != nil { 991 return api.mock.ListDatumStream.handler(req, serv) 992 } 993 return errors.Errorf("unhandled pachd mock pps.ListDatumStream") 994 } 995 func (api *ppsServerAPI) RestartDatum(ctx context.Context, req *pps.RestartDatumRequest) (*types.Empty, error) { 996 if api.mock.RestartDatum.handler != nil { 997 return api.mock.RestartDatum.handler(ctx, req) 998 } 999 return nil, errors.Errorf("unhandled pachd mock pps.RestartDatum") 1000 } 1001 func (api *ppsServerAPI) CreatePipeline(ctx context.Context, req *pps.CreatePipelineRequest) (*types.Empty, error) { 1002 if api.mock.CreatePipeline.handler != nil { 1003 return api.mock.CreatePipeline.handler(ctx, req) 1004 } 1005 return nil, errors.Errorf("unhandled pachd mock pps.CreatePipeline") 1006 } 1007 func (api *ppsServerAPI) InspectPipeline(ctx context.Context, req *pps.InspectPipelineRequest) (*pps.PipelineInfo, error) { 1008 if api.mock.InspectPipeline.handler != nil { 1009 return api.mock.InspectPipeline.handler(ctx, req) 1010 } 1011 return nil, errors.Errorf("unhandled pachd mock pps.InspectPipeline") 1012 } 1013 func (api *ppsServerAPI) ListPipeline(ctx context.Context, req *pps.ListPipelineRequest) (*pps.PipelineInfos, error) { 1014 if api.mock.ListPipeline.handler != nil { 1015 return api.mock.ListPipeline.handler(ctx, req) 1016 } 1017 return nil, errors.Errorf("unhandled pachd mock pps.ListPipeline") 1018 } 1019 func (api *ppsServerAPI) DeletePipeline(ctx context.Context, req *pps.DeletePipelineRequest) (*types.Empty, error) { 1020 if api.mock.DeletePipeline.handler != nil { 1021 return api.mock.DeletePipeline.handler(ctx, req) 1022 } 1023 return nil, errors.Errorf("unhandled pachd mock pps.DeletePipeline") 1024 } 1025 func (api *ppsServerAPI) StartPipeline(ctx context.Context, req *pps.StartPipelineRequest) (*types.Empty, error) { 1026 if api.mock.StartPipeline.handler != nil { 1027 return api.mock.StartPipeline.handler(ctx, req) 1028 } 1029 return nil, errors.Errorf("unhandled pachd mock pps.StartPipeline") 1030 } 1031 func (api *ppsServerAPI) StopPipeline(ctx context.Context, req *pps.StopPipelineRequest) (*types.Empty, error) { 1032 if api.mock.StopPipeline.handler != nil { 1033 return api.mock.StopPipeline.handler(ctx, req) 1034 } 1035 return nil, errors.Errorf("unhandled pachd mock pps.StopPipeline") 1036 } 1037 func (api *ppsServerAPI) RunPipeline(ctx context.Context, req *pps.RunPipelineRequest) (*types.Empty, error) { 1038 if api.mock.RunPipeline.handler != nil { 1039 return api.mock.RunPipeline.handler(ctx, req) 1040 } 1041 return nil, errors.Errorf("unhandled pachd mock pps.RunPipeline") 1042 } 1043 func (api *ppsServerAPI) RunCron(ctx context.Context, req *pps.RunCronRequest) (*types.Empty, error) { 1044 if api.mock.RunCron.handler != nil { 1045 return api.mock.RunCron.handler(ctx, req) 1046 } 1047 return nil, errors.Errorf("unhandled pachd mock pps.RunCron") 1048 } 1049 func (api *ppsServerAPI) CreateSecret(ctx context.Context, req *pps.CreateSecretRequest) (*types.Empty, error) { 1050 if api.mock.CreateSecret.handler != nil { 1051 return api.mock.CreateSecret.handler(ctx, req) 1052 } 1053 return nil, errors.Errorf("unhandled pachd mock pps.CreateSecret") 1054 } 1055 func (api *ppsServerAPI) DeleteSecret(ctx context.Context, req *pps.DeleteSecretRequest) (*types.Empty, error) { 1056 if api.mock.DeleteSecret.handler != nil { 1057 return api.mock.DeleteSecret.handler(ctx, req) 1058 } 1059 return nil, errors.Errorf("unhandled pachd mock pps.DeleteSecret") 1060 } 1061 func (api *ppsServerAPI) InspectSecret(ctx context.Context, req *pps.InspectSecretRequest) (*pps.SecretInfo, error) { 1062 if api.mock.InspectSecret.handler != nil { 1063 return api.mock.InspectSecret.handler(ctx, req) 1064 } 1065 return nil, errors.Errorf("unhandled pachd mock pps.InspectSecret") 1066 } 1067 func (api *ppsServerAPI) ListSecret(ctx context.Context, in *types.Empty) (*pps.SecretInfos, error) { 1068 if api.mock.ListSecret.handler != nil { 1069 return api.mock.ListSecret.handler(ctx, in) 1070 } 1071 return nil, errors.Errorf("unhandled pachd mock pps.ListSecret") 1072 } 1073 func (api *ppsServerAPI) DeleteAll(ctx context.Context, req *types.Empty) (*types.Empty, error) { 1074 if api.mock.DeleteAll.handler != nil { 1075 return api.mock.DeleteAll.handler(ctx, req) 1076 } 1077 return nil, errors.Errorf("unhandled pachd mock pps.DeleteAll") 1078 } 1079 func (api *ppsServerAPI) GetLogs(req *pps.GetLogsRequest, serv pps.API_GetLogsServer) error { 1080 if api.mock.GetLogs.handler != nil { 1081 return api.mock.GetLogs.handler(req, serv) 1082 } 1083 return errors.Errorf("unhandled pachd mock pps.GetLogs") 1084 } 1085 func (api *ppsServerAPI) GarbageCollect(ctx context.Context, req *pps.GarbageCollectRequest) (*pps.GarbageCollectResponse, error) { 1086 if api.mock.GarbageCollect.handler != nil { 1087 return api.mock.GarbageCollect.handler(ctx, req) 1088 } 1089 return nil, errors.Errorf("unhandled pachd mock pps.GarbageCollect") 1090 } 1091 func (api *ppsServerAPI) ActivateAuth(ctx context.Context, req *pps.ActivateAuthRequest) (*pps.ActivateAuthResponse, error) { 1092 if api.mock.ActivateAuth.handler != nil { 1093 return api.mock.ActivateAuth.handler(ctx, req) 1094 } 1095 return nil, errors.Errorf("unhandled pachd mock pps.ActivateAuth") 1096 } 1097 1098 /* Transaction Server Mocks */ 1099 1100 type batchTransactionFunc func(context.Context, *transaction.BatchTransactionRequest) (*transaction.TransactionInfo, error) 1101 type startTransactionFunc func(context.Context, *transaction.StartTransactionRequest) (*transaction.Transaction, error) 1102 type inspectTransactionFunc func(context.Context, *transaction.InspectTransactionRequest) (*transaction.TransactionInfo, error) 1103 type deleteTransactionFunc func(context.Context, *transaction.DeleteTransactionRequest) (*types.Empty, error) 1104 type listTransactionFunc func(context.Context, *transaction.ListTransactionRequest) (*transaction.TransactionInfos, error) 1105 type finishTransactionFunc func(context.Context, *transaction.FinishTransactionRequest) (*transaction.TransactionInfo, error) 1106 type deleteAllTransactionFunc func(context.Context, *transaction.DeleteAllRequest) (*types.Empty, error) 1107 1108 type mockBatchTransaction struct{ handler batchTransactionFunc } 1109 type mockStartTransaction struct{ handler startTransactionFunc } 1110 type mockInspectTransaction struct{ handler inspectTransactionFunc } 1111 type mockDeleteTransaction struct{ handler deleteTransactionFunc } 1112 type mockListTransaction struct{ handler listTransactionFunc } 1113 type mockFinishTransaction struct{ handler finishTransactionFunc } 1114 type mockDeleteAllTransaction struct{ handler deleteAllTransactionFunc } 1115 1116 func (mock *mockBatchTransaction) Use(cb batchTransactionFunc) { mock.handler = cb } 1117 func (mock *mockStartTransaction) Use(cb startTransactionFunc) { mock.handler = cb } 1118 func (mock *mockInspectTransaction) Use(cb inspectTransactionFunc) { mock.handler = cb } 1119 func (mock *mockDeleteTransaction) Use(cb deleteTransactionFunc) { mock.handler = cb } 1120 func (mock *mockListTransaction) Use(cb listTransactionFunc) { mock.handler = cb } 1121 func (mock *mockFinishTransaction) Use(cb finishTransactionFunc) { mock.handler = cb } 1122 func (mock *mockDeleteAllTransaction) Use(cb deleteAllTransactionFunc) { mock.handler = cb } 1123 1124 type transactionServerAPI struct { 1125 mock *mockTransactionServer 1126 } 1127 1128 type mockTransactionServer struct { 1129 api transactionServerAPI 1130 BatchTransaction mockBatchTransaction 1131 StartTransaction mockStartTransaction 1132 InspectTransaction mockInspectTransaction 1133 DeleteTransaction mockDeleteTransaction 1134 ListTransaction mockListTransaction 1135 FinishTransaction mockFinishTransaction 1136 DeleteAll mockDeleteAllTransaction 1137 } 1138 1139 func (api *transactionServerAPI) BatchTransaction(ctx context.Context, req *transaction.BatchTransactionRequest) (*transaction.TransactionInfo, error) { 1140 if api.mock.BatchTransaction.handler != nil { 1141 return api.mock.BatchTransaction.handler(ctx, req) 1142 } 1143 return nil, errors.Errorf("unhandled pachd mock transaction.BatchTransaction") 1144 } 1145 func (api *transactionServerAPI) StartTransaction(ctx context.Context, req *transaction.StartTransactionRequest) (*transaction.Transaction, error) { 1146 if api.mock.StartTransaction.handler != nil { 1147 return api.mock.StartTransaction.handler(ctx, req) 1148 } 1149 return nil, errors.Errorf("unhandled pachd mock transaction.StartTransaction") 1150 } 1151 func (api *transactionServerAPI) InspectTransaction(ctx context.Context, req *transaction.InspectTransactionRequest) (*transaction.TransactionInfo, error) { 1152 if api.mock.InspectTransaction.handler != nil { 1153 return api.mock.InspectTransaction.handler(ctx, req) 1154 } 1155 return nil, errors.Errorf("unhandled pachd mock transaction.InspectTransaction") 1156 } 1157 func (api *transactionServerAPI) DeleteTransaction(ctx context.Context, req *transaction.DeleteTransactionRequest) (*types.Empty, error) { 1158 if api.mock.DeleteTransaction.handler != nil { 1159 return api.mock.DeleteTransaction.handler(ctx, req) 1160 } 1161 return nil, errors.Errorf("unhandled pachd mock transaction.DeleteTransaction") 1162 } 1163 func (api *transactionServerAPI) ListTransaction(ctx context.Context, req *transaction.ListTransactionRequest) (*transaction.TransactionInfos, error) { 1164 if api.mock.ListTransaction.handler != nil { 1165 return api.mock.ListTransaction.handler(ctx, req) 1166 } 1167 return nil, errors.Errorf("unhandled pachd mock transaction.ListTransaction") 1168 } 1169 func (api *transactionServerAPI) FinishTransaction(ctx context.Context, req *transaction.FinishTransactionRequest) (*transaction.TransactionInfo, error) { 1170 if api.mock.FinishTransaction.handler != nil { 1171 return api.mock.FinishTransaction.handler(ctx, req) 1172 } 1173 return nil, errors.Errorf("unhandled pachd mock transaction.FinishTransaction") 1174 } 1175 func (api *transactionServerAPI) DeleteAll(ctx context.Context, req *transaction.DeleteAllRequest) (*types.Empty, error) { 1176 if api.mock.DeleteAll.handler != nil { 1177 return api.mock.DeleteAll.handler(ctx, req) 1178 } 1179 return nil, errors.Errorf("unhandled pachd mock transaction.DeleteAll") 1180 } 1181 1182 /* Version Server Mocks */ 1183 1184 type getVersionFunc func(context.Context, *types.Empty) (*version.Version, error) 1185 1186 type mockGetVersion struct{ handler getVersionFunc } 1187 1188 func (mock *mockGetVersion) Use(cb getVersionFunc) { mock.handler = cb } 1189 1190 type versionServerAPI struct { 1191 mock *mockVersionServer 1192 } 1193 1194 type mockVersionServer struct { 1195 api versionServerAPI 1196 GetVersion mockGetVersion 1197 } 1198 1199 func (api *versionServerAPI) GetVersion(ctx context.Context, req *types.Empty) (*version.Version, error) { 1200 if api.mock.GetVersion.handler != nil { 1201 return api.mock.GetVersion.handler(ctx, req) 1202 } 1203 return nil, errors.Errorf("unhandled pachd mock version.GetVersion") 1204 } 1205 1206 /* Object Server Mocks */ 1207 1208 type putObjectFunc func(pfs.ObjectAPI_PutObjectServer) error 1209 type putObjectSplitFunc func(pfs.ObjectAPI_PutObjectSplitServer) error 1210 type putObjectsFunc func(pfs.ObjectAPI_PutObjectsServer) error 1211 type createObjectFunc func(context.Context, *pfs.CreateObjectRequest) (*types.Empty, error) 1212 type getObjectFunc func(*pfs.Object, pfs.ObjectAPI_GetObjectServer) error 1213 type getObjectsFunc func(*pfs.GetObjectsRequest, pfs.ObjectAPI_GetObjectsServer) error 1214 type putBlockFunc func(pfs.ObjectAPI_PutBlockServer) error 1215 type getBlockFunc func(*pfs.GetBlockRequest, pfs.ObjectAPI_GetBlockServer) error 1216 type getBlocksFunc func(*pfs.GetBlocksRequest, pfs.ObjectAPI_GetBlocksServer) error 1217 type listBlockFunc func(*pfs.ListBlockRequest, pfs.ObjectAPI_ListBlockServer) error 1218 type tagObjectFunc func(context.Context, *pfs.TagObjectRequest) (*types.Empty, error) 1219 type inspectObjectFunc func(context.Context, *pfs.Object) (*pfs.ObjectInfo, error) 1220 type checkObjectFunc func(context.Context, *pfs.CheckObjectRequest) (*pfs.CheckObjectResponse, error) 1221 type listObjectsFunc func(*pfs.ListObjectsRequest, pfs.ObjectAPI_ListObjectsServer) error 1222 type deleteObjectsFunc func(context.Context, *pfs.DeleteObjectsRequest) (*pfs.DeleteObjectsResponse, error) 1223 type getTagFunc func(*pfs.Tag, pfs.ObjectAPI_GetTagServer) error 1224 type inspectTagFunc func(context.Context, *pfs.Tag) (*pfs.ObjectInfo, error) 1225 type listTagsFunc func(*pfs.ListTagsRequest, pfs.ObjectAPI_ListTagsServer) error 1226 type deleteTagsFunc func(context.Context, *pfs.DeleteTagsRequest) (*pfs.DeleteTagsResponse, error) 1227 type compactFunc func(context.Context, *types.Empty) (*types.Empty, error) 1228 type putObjDirectFunc func(pfs.ObjectAPI_PutObjDirectServer) error 1229 type getObjDirectFunc func(*pfs.GetObjDirectRequest, pfs.ObjectAPI_GetObjDirectServer) error 1230 type deleteObjDirectFunc func(context.Context, *pfs.DeleteObjDirectRequest) (*types.Empty, error) 1231 1232 type mockPutObject struct{ handler putObjectFunc } 1233 type mockPutObjectSplit struct{ handler putObjectSplitFunc } 1234 type mockPutObjects struct{ handler putObjectsFunc } 1235 type mockCreateObject struct{ handler createObjectFunc } 1236 type mockGetObject struct{ handler getObjectFunc } 1237 type mockGetObjects struct{ handler getObjectsFunc } 1238 type mockPutBlock struct{ handler putBlockFunc } 1239 type mockGetBlock struct{ handler getBlockFunc } 1240 type mockGetBlocks struct{ handler getBlocksFunc } 1241 type mockListBlock struct{ handler listBlockFunc } 1242 type mockTagObject struct{ handler tagObjectFunc } 1243 type mockInspectObject struct{ handler inspectObjectFunc } 1244 type mockCheckObject struct{ handler checkObjectFunc } 1245 type mockListObjects struct{ handler listObjectsFunc } 1246 type mockDeleteObjects struct{ handler deleteObjectsFunc } 1247 type mockGetTag struct{ handler getTagFunc } 1248 type mockInspectTag struct{ handler inspectTagFunc } 1249 type mockListTags struct{ handler listTagsFunc } 1250 type mockDeleteTags struct{ handler deleteTagsFunc } 1251 type mockCompact struct{ handler compactFunc } 1252 type mockPutObjDirect struct{ handler putObjDirectFunc } 1253 type mockGetObjDirect struct{ handler getObjDirectFunc } 1254 type mockDeleteObjDirect struct{ handler deleteObjDirectFunc } 1255 1256 func (mock *mockPutObject) Use(cb putObjectFunc) { mock.handler = cb } 1257 func (mock *mockPutObjectSplit) Use(cb putObjectSplitFunc) { mock.handler = cb } 1258 func (mock *mockPutObjects) Use(cb putObjectsFunc) { mock.handler = cb } 1259 func (mock *mockCreateObject) Use(cb createObjectFunc) { mock.handler = cb } 1260 func (mock *mockGetObject) Use(cb getObjectFunc) { mock.handler = cb } 1261 func (mock *mockGetObjects) Use(cb getObjectsFunc) { mock.handler = cb } 1262 func (mock *mockPutBlock) Use(cb putBlockFunc) { mock.handler = cb } 1263 func (mock *mockGetBlock) Use(cb getBlockFunc) { mock.handler = cb } 1264 func (mock *mockGetBlocks) Use(cb getBlocksFunc) { mock.handler = cb } 1265 func (mock *mockListBlock) Use(cb listBlockFunc) { mock.handler = cb } 1266 func (mock *mockTagObject) Use(cb tagObjectFunc) { mock.handler = cb } 1267 func (mock *mockInspectObject) Use(cb inspectObjectFunc) { mock.handler = cb } 1268 func (mock *mockCheckObject) Use(cb checkObjectFunc) { mock.handler = cb } 1269 func (mock *mockListObjects) Use(cb listObjectsFunc) { mock.handler = cb } 1270 func (mock *mockDeleteObjects) Use(cb deleteObjectsFunc) { mock.handler = cb } 1271 func (mock *mockGetTag) Use(cb getTagFunc) { mock.handler = cb } 1272 func (mock *mockInspectTag) Use(cb inspectTagFunc) { mock.handler = cb } 1273 func (mock *mockListTags) Use(cb listTagsFunc) { mock.handler = cb } 1274 func (mock *mockDeleteTags) Use(cb deleteTagsFunc) { mock.handler = cb } 1275 func (mock *mockCompact) Use(cb compactFunc) { mock.handler = cb } 1276 func (mock *mockPutObjDirect) Use(cb putObjDirectFunc) { mock.handler = cb } 1277 func (mock *mockGetObjDirect) Use(cb getObjDirectFunc) { mock.handler = cb } 1278 func (mock *mockDeleteObjDirect) Use(cb deleteObjDirectFunc) { mock.handler = cb } 1279 1280 type objectServerAPI struct { 1281 mock *mockObjectServer 1282 } 1283 1284 type mockObjectServer struct { 1285 api objectServerAPI 1286 PutObject mockPutObject 1287 PutObjectSplit mockPutObjectSplit 1288 PutObjects mockPutObjects 1289 CreateObject mockCreateObject 1290 GetObject mockGetObject 1291 GetObjects mockGetObjects 1292 PutBlock mockPutBlock 1293 GetBlock mockGetBlock 1294 GetBlocks mockGetBlocks 1295 ListBlock mockListBlock 1296 TagObject mockTagObject 1297 InspectObject mockInspectObject 1298 CheckObject mockCheckObject 1299 ListObjects mockListObjects 1300 DeleteObjects mockDeleteObjects 1301 GetTag mockGetTag 1302 InspectTag mockInspectTag 1303 ListTags mockListTags 1304 DeleteTags mockDeleteTags 1305 Compact mockCompact 1306 PutObjDirect mockPutObjDirect 1307 GetObjDirect mockGetObjDirect 1308 DeleteObjDirect mockDeleteObjDirect 1309 } 1310 1311 func (api *objectServerAPI) PutObject(serv pfs.ObjectAPI_PutObjectServer) error { 1312 if api.mock.PutObject.handler != nil { 1313 return api.mock.PutObject.handler(serv) 1314 } 1315 return errors.Errorf("unhandled pachd mock object.PutObject") 1316 } 1317 func (api *objectServerAPI) PutObjectSplit(serv pfs.ObjectAPI_PutObjectSplitServer) error { 1318 if api.mock.PutObjectSplit.handler != nil { 1319 return api.mock.PutObjectSplit.handler(serv) 1320 } 1321 return errors.Errorf("unhandled pachd mock object.PutObjectSplit") 1322 } 1323 func (api *objectServerAPI) PutObjects(serv pfs.ObjectAPI_PutObjectsServer) error { 1324 if api.mock.PutObjects.handler != nil { 1325 return api.mock.PutObjects.handler(serv) 1326 } 1327 return errors.Errorf("unhandled pachd mock object.PutObjects") 1328 } 1329 func (api *objectServerAPI) CreateObject(ctx context.Context, serv *pfs.CreateObjectRequest) (*types.Empty, error) { 1330 if api.mock.CreateObject.handler != nil { 1331 return api.mock.CreateObject.handler(ctx, serv) 1332 } 1333 return nil, errors.Errorf("unhandled pachd mock object.CreateObject") 1334 } 1335 func (api *objectServerAPI) GetObject(req *pfs.Object, serv pfs.ObjectAPI_GetObjectServer) error { 1336 if api.mock.GetObject.handler != nil { 1337 return api.mock.GetObject.handler(req, serv) 1338 } 1339 return errors.Errorf("unhandled pachd mock object.GetObject") 1340 } 1341 func (api *objectServerAPI) GetObjects(req *pfs.GetObjectsRequest, serv pfs.ObjectAPI_GetObjectsServer) error { 1342 if api.mock.GetObjects.handler != nil { 1343 return api.mock.GetObjects.handler(req, serv) 1344 } 1345 return errors.Errorf("unhandled pachd mock object.GetObjects") 1346 } 1347 func (api *objectServerAPI) PutBlock(serv pfs.ObjectAPI_PutBlockServer) error { 1348 if api.mock.PutBlock.handler != nil { 1349 return api.mock.PutBlock.handler(serv) 1350 } 1351 return errors.Errorf("unhandled pachd mock object.PutBlock") 1352 } 1353 func (api *objectServerAPI) GetBlock(req *pfs.GetBlockRequest, serv pfs.ObjectAPI_GetBlockServer) error { 1354 if api.mock.GetBlock.handler != nil { 1355 return api.mock.GetBlock.handler(req, serv) 1356 } 1357 return errors.Errorf("unhandled pachd mock object.GetBlock") 1358 } 1359 func (api *objectServerAPI) GetBlocks(req *pfs.GetBlocksRequest, serv pfs.ObjectAPI_GetBlocksServer) error { 1360 if api.mock.GetBlocks.handler != nil { 1361 return api.mock.GetBlocks.handler(req, serv) 1362 } 1363 return errors.Errorf("unhandled pachd mock object.GetBlocks") 1364 } 1365 func (api *objectServerAPI) ListBlock(req *pfs.ListBlockRequest, serv pfs.ObjectAPI_ListBlockServer) error { 1366 if api.mock.ListBlock.handler != nil { 1367 return api.mock.ListBlock.handler(req, serv) 1368 } 1369 return errors.Errorf("unhandled pachd mock object.ListBlock") 1370 } 1371 func (api *objectServerAPI) TagObject(ctx context.Context, req *pfs.TagObjectRequest) (*types.Empty, error) { 1372 if api.mock.TagObject.handler != nil { 1373 return api.mock.TagObject.handler(ctx, req) 1374 } 1375 return nil, errors.Errorf("unhandled pachd mock object.TagObject") 1376 } 1377 func (api *objectServerAPI) InspectObject(ctx context.Context, req *pfs.Object) (*pfs.ObjectInfo, error) { 1378 if api.mock.InspectObject.handler != nil { 1379 return api.mock.InspectObject.handler(ctx, req) 1380 } 1381 return nil, errors.Errorf("unhandled pachd mock object.InspectObject") 1382 } 1383 func (api *objectServerAPI) CheckObject(ctx context.Context, req *pfs.CheckObjectRequest) (*pfs.CheckObjectResponse, error) { 1384 if api.mock.CheckObject.handler != nil { 1385 return api.mock.CheckObject.handler(ctx, req) 1386 } 1387 return nil, errors.Errorf("unhandled pachd mock object.CheckObject") 1388 } 1389 func (api *objectServerAPI) ListObjects(req *pfs.ListObjectsRequest, serv pfs.ObjectAPI_ListObjectsServer) error { 1390 if api.mock.ListObjects.handler != nil { 1391 return api.mock.ListObjects.handler(req, serv) 1392 } 1393 return errors.Errorf("unhandled pachd mock object.ListObjects") 1394 } 1395 func (api *objectServerAPI) DeleteObjects(ctx context.Context, req *pfs.DeleteObjectsRequest) (*pfs.DeleteObjectsResponse, error) { 1396 if api.mock.DeleteObjects.handler != nil { 1397 return api.mock.DeleteObjects.handler(ctx, req) 1398 } 1399 return nil, errors.Errorf("unhandled pachd mock object.DeleteObjects") 1400 } 1401 func (api *objectServerAPI) GetTag(req *pfs.Tag, serv pfs.ObjectAPI_GetTagServer) error { 1402 if api.mock.GetTag.handler != nil { 1403 return api.mock.GetTag.handler(req, serv) 1404 } 1405 return errors.Errorf("unhandled pachd mock object.GetTag") 1406 } 1407 func (api *objectServerAPI) InspectTag(ctx context.Context, req *pfs.Tag) (*pfs.ObjectInfo, error) { 1408 if api.mock.InspectTag.handler != nil { 1409 return api.mock.InspectTag.handler(ctx, req) 1410 } 1411 return nil, errors.Errorf("unhandled pachd mock object.InspectTag") 1412 } 1413 func (api *objectServerAPI) ListTags(req *pfs.ListTagsRequest, serv pfs.ObjectAPI_ListTagsServer) error { 1414 if api.mock.ListTags.handler != nil { 1415 return api.mock.ListTags.handler(req, serv) 1416 } 1417 return errors.Errorf("unhandled pachd mock object.ListTags") 1418 } 1419 func (api *objectServerAPI) DeleteTags(ctx context.Context, req *pfs.DeleteTagsRequest) (*pfs.DeleteTagsResponse, error) { 1420 if api.mock.DeleteTags.handler != nil { 1421 return api.mock.DeleteTags.handler(ctx, req) 1422 } 1423 return nil, errors.Errorf("unhandled pachd mock object.DeleteTags") 1424 } 1425 func (api *objectServerAPI) Compact(ctx context.Context, req *types.Empty) (*types.Empty, error) { 1426 if api.mock.Compact.handler != nil { 1427 return api.mock.Compact.handler(ctx, req) 1428 } 1429 return nil, errors.Errorf("unhandled pachd mock object.Compact") 1430 } 1431 func (api *objectServerAPI) PutObjDirect(serv pfs.ObjectAPI_PutObjDirectServer) error { 1432 if api.mock.PutObjDirect.handler != nil { 1433 return api.mock.PutObjDirect.handler(serv) 1434 } 1435 return errors.Errorf("unhandled pachd mock object.PutObjDirect") 1436 } 1437 func (api *objectServerAPI) GetObjDirect(req *pfs.GetObjDirectRequest, serv pfs.ObjectAPI_GetObjDirectServer) error { 1438 if api.mock.GetObjDirect.handler != nil { 1439 return api.mock.GetObjDirect.handler(req, serv) 1440 } 1441 return errors.Errorf("unhandled pachd mock object.GetObjDirect") 1442 } 1443 func (api *objectServerAPI) DeleteObjDirect(ctx context.Context, req *pfs.DeleteObjDirectRequest) (*types.Empty, error) { 1444 if api.mock.DeleteObjDirect.handler != nil { 1445 return api.mock.DeleteObjDirect.handler(ctx, req) 1446 } 1447 return nil, errors.Errorf("unhandled pachd mock object.GetObjDirect") 1448 } 1449 1450 // MockPachd provides an interface for running the interface for a Pachd API 1451 // server locally without any of its dependencies. Tests may mock out specific 1452 // API calls by providing a handler function, and later check information about 1453 // the mocked calls. 1454 type MockPachd struct { 1455 cancel context.CancelFunc 1456 errchan chan error 1457 1458 Addr net.Addr 1459 1460 Object mockObjectServer 1461 PFS mockPFSServer 1462 PPS mockPPSServer 1463 Auth mockAuthServer 1464 Transaction mockTransactionServer 1465 Enterprise mockEnterpriseServer 1466 Version mockVersionServer 1467 Admin mockAdminServer 1468 } 1469 1470 // NewMockPachd constructs a mock Pachd API server whose behavior can be 1471 // controlled through the MockPachd instance. By default, all API calls will 1472 // error, unless a handler is specified. 1473 func NewMockPachd(ctx context.Context) (*MockPachd, error) { 1474 mock := &MockPachd{ 1475 errchan: make(chan error), 1476 } 1477 1478 ctx, mock.cancel = context.WithCancel(ctx) 1479 1480 mock.Object.api.mock = &mock.Object 1481 mock.PFS.api.mock = &mock.PFS 1482 mock.PPS.api.mock = &mock.PPS 1483 mock.Auth.api.mock = &mock.Auth 1484 mock.Transaction.api.mock = &mock.Transaction 1485 mock.Enterprise.api.mock = &mock.Enterprise 1486 mock.Version.api.mock = &mock.Version 1487 mock.Admin.api.mock = &mock.Admin 1488 1489 server, err := grpcutil.NewServer(ctx, false) 1490 if err != nil { 1491 return nil, err 1492 } 1493 1494 admin.RegisterAPIServer(server.Server, &mock.Admin.api) 1495 auth.RegisterAPIServer(server.Server, &mock.Auth.api) 1496 enterprise.RegisterAPIServer(server.Server, &mock.Enterprise.api) 1497 pfs.RegisterObjectAPIServer(server.Server, &mock.Object.api) 1498 pfs.RegisterAPIServer(server.Server, &mock.PFS.api) 1499 pps.RegisterAPIServer(server.Server, &mock.PPS.api) 1500 transaction.RegisterAPIServer(server.Server, &mock.Transaction.api) 1501 version.RegisterAPIServer(server.Server, &mock.Version.api) 1502 1503 listener, err := server.ListenTCP("localhost", 0) 1504 if err != nil { 1505 return nil, err 1506 } 1507 1508 go func() { 1509 mock.errchan <- server.Wait() 1510 close(mock.errchan) 1511 }() 1512 1513 mock.Addr = listener.Addr() 1514 1515 return mock, nil 1516 } 1517 1518 // Err returns a read-only channel that will receive the first error that occurs 1519 // in the server group (stopping all the servers). 1520 func (mock *MockPachd) Err() <-chan error { 1521 return mock.errchan 1522 } 1523 1524 // Close will cancel the mock Pachd API server goroutine and return its result 1525 func (mock *MockPachd) Close() error { 1526 mock.cancel() 1527 return <-mock.errchan 1528 }