Skip to content

Commit a498f05

Browse files
committed
fix
1 parent 9fab67a commit a498f05

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

components/server/src/api/teams.spec.db.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import { TeamsService as TeamsServiceDefinition } from "@gitpod/public-api/lib/g
1616
import { WorkspaceStarter } from "../workspace/workspace-starter";
1717
import { UserService } from "../user/user-service";
1818
import { APITeamsService } from "./teams";
19+
import { v4 as uuidv4 } from "uuid";
1920
import * as chai from "chai";
21+
import { GetTeamRequest } from "@gitpod/public-api/lib/gitpod/experimental/v1/teams_pb";
2022

2123
const expect = chai.expect;
2224

@@ -58,15 +60,34 @@ export class APITeamsServiceSpec {
5860
});
5961
}
6062

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() {
6281
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");
6788
} catch (err) {
6889
expect(err).to.be.an.instanceof(ConnectError);
69-
expect(err.code).to.equal(Code.InvalidArgument);
90+
expect(err.code).to.equal(Code.NotFound);
7091
}
7192
}
7293
}

components/server/src/api/teams.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ export class APITeamsService implements ServiceImpl<typeof TeamServiceInterface>
4444
public async getTeam(req: GetTeamRequest): Promise<GetTeamResponse> {
4545
const { teamId } = req;
4646

47+
console.log("handling get team", teamId);
48+
4749
if (!teamId || !validate(teamId)) {
4850
throw new ConnectError("Invalid argument: teamId", Code.InvalidArgument);
4951
}
5052

5153
const team = await this.teamDB.findTeamById(teamId);
54+
console.log(team);
5255
if (!team) {
5356
throw new ConnectError(`Team (ID: ${teamId}) does not exist`, Code.NotFound);
5457
}

0 commit comments

Comments
 (0)