Skip to content

Commit 177367e

Browse files
Fix GitHub Integration tests (#20363)
1 parent 4c69ad0 commit 177367e

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

components/server/src/dev/dev-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export namespace DevData {
5454
export function createGitHubTestToken(): Token {
5555
if (!process.env.GITPOD_TEST_TOKEN_GITHUB) {
5656
console.error(
57-
`GITPOD_TEST_TOKEN_GITHUB env var is not set\n\n\t export GITPOD_TEST_TOKEN_GITHUB='{"username": "gitpod-test", "token": $AZURE_TOKEN}'`,
57+
`GITPOD_TEST_TOKEN_GITHUB env var is not set\n\n\t export GITPOD_TEST_TOKEN_GITHUB='{"username": "gitpod-test", "value": $GITHUB_TOKEN}'`,
5858
);
5959
}
6060
return {

components/server/src/errors/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export namespace NotFoundError {
2020
repoName: string,
2121
errorMessage: string = "Repository not found.",
2222
) {
23-
const lastUpdate = (token && token.updateDate) || "";
23+
const lastUpdate = (token && token.updateDate) ?? "";
2424
const userScopes = token ? [...token.scopes] : [];
2525

2626
const userIsOwner = owner == user.name; // TODO: shouldn't this be a comparison with `identity.authName`?

components/server/src/github/github-context-parser.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ class TestGithubContextParser {
8787

8888
static readonly BLO_BLA_ERROR_DATA = {
8989
host: "github.com",
90-
lastUpdate: undefined,
90+
lastUpdate: "",
9191
owner: "blo",
9292
repoName: "bla",
9393
userIsOwner: false,
9494
userScopes: ["user:email", "public_repo", "repo"],
95+
errorMessage: "Could not resolve to a Repository with the name 'blo/bla'.",
9596
};
9697

9798
protected getTestBranches(): BranchRef[] {
@@ -180,12 +181,12 @@ class TestGithubContextParser {
180181
const result = await this.parser.handle(
181182
{},
182183
this.user,
183-
"https://github.com/eclipse-theia/theia/tree/master/LICENSE",
184+
"https://github.com/eclipse-theia/theia/tree/master/LICENSE-EPL",
184185
);
185186
expect(result).to.deep.include({
186187
ref: "master",
187188
refType: "branch",
188-
path: "LICENSE",
189+
path: "LICENSE-EPL",
189190
isFile: true,
190191
repository: {
191192
host: "github.com",

components/server/src/github/github-repository-provider.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class TestGithubContextRepositoryProvider {
8181

8282
@test public async testGetUserRepos() {
8383
const result = await this.provider.getUserRepos(this.user);
84-
expect(result).to.include({ url: "https://github.com/gitpod-io/gitpod", name: "gitpod" });
84+
expect(result).to.deep.include({ url: "https://github.com/gitpod-integration-test/example", name: "example" });
8585
}
8686
}
8787
module.exports = new TestGithubContextRepositoryProvider(); // Only to circumvent no usage warning :-/

components/server/src/github/github-repository-provider.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,20 @@ export class GithubRepositoryProvider implements RepositoryProvider {
215215
}`,
216216
);
217217

218-
let repos: RepositoryInfo[] = [];
219-
218+
const repos: RepositoryInfo[] = [];
220219
for (const type of ["contributedTo", "original", "forked"]) {
221220
const nodes = result.data.viewer[type]?.nodes;
222221
if (nodes) {
223-
repos = nodes.map((n: any): RepositoryInfo => {
222+
const reposInSection: RepositoryInfo[] = nodes.map((n: any) => {
224223
return {
225224
name: n.name,
226225
url: n.url,
227226
};
228227
});
228+
repos.push(...reposInSection);
229229
}
230230
}
231+
231232
return repos;
232233
}
233234

0 commit comments

Comments
 (0)