@@ -16,7 +16,9 @@ import { TeamsService as TeamsServiceDefinition } from "@gitpod/public-api/lib/g
16
16
import { WorkspaceStarter } from "../workspace/workspace-starter" ;
17
17
import { UserService } from "../user/user-service" ;
18
18
import { APITeamsService } from "./teams" ;
19
+ import { v4 as uuidv4 } from "uuid" ;
19
20
import * as chai from "chai" ;
21
+ import { GetTeamRequest } from "@gitpod/public-api/lib/gitpod/experimental/v1/teams_pb" ;
20
22
21
23
const expect = chai . expect ;
22
24
@@ -58,15 +60,34 @@ export class APITeamsServiceSpec {
58
60
} ) ;
59
61
}
60
62
61
- @test async getTeam_rejectsMissingTeamID ( ) {
63
+ @test async getTeam_invalidArgument ( ) {
64
+ const payloads = [
65
+ new GetTeamRequest ( { } ) , // empty
66
+ new GetTeamRequest ( { teamId : "foo-bar" } ) , // not a valid UUID
67
+ ] ;
68
+
69
+ for ( let payload of payloads ) {
70
+ try {
71
+ await this . client . getTeam ( payload ) ;
72
+ expect . fail ( "get team did not throw an exception" ) ;
73
+ } catch ( err ) {
74
+ expect ( err ) . to . be . an . instanceof ( ConnectError ) ;
75
+ expect ( err . code ) . to . equal ( Code . InvalidArgument ) ;
76
+ }
77
+ }
78
+ }
79
+
80
+ @test async getTeam_notFoundWhenTeamDoesNotExist ( ) {
62
81
try {
63
- await this . client . getTeam ( {
64
- teamId : "" ,
65
- } ) ;
66
- expect . fail ( "getteam did not throw an exception" ) ;
82
+ await this . client . getTeam (
83
+ new GetTeamRequest ( {
84
+ teamId : uuidv4 ( ) ,
85
+ } ) ,
86
+ ) ;
87
+ expect . fail ( "get team did not throw an exception" ) ;
67
88
} catch ( err ) {
68
89
expect ( err ) . to . be . an . instanceof ( ConnectError ) ;
69
- expect ( err . code ) . to . equal ( Code . InvalidArgument ) ;
90
+ expect ( err . code ) . to . equal ( Code . NotFound ) ;
70
91
}
71
92
}
72
93
}
0 commit comments