Skip to content

Commit e5eb61d

Browse files
Fix Bitbucket Server repository provider tests (#20364)
1 parent 5c51d08 commit e5eb61d

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

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

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TestBitbucketServerRepositoryProvider {
3131
verified: true,
3232
description: "",
3333
icon: "",
34-
host: "bitbucket.gitpod-self-hosted.com",
34+
host: "bitbucket.gitpod-dev.com",
3535
oauth: {
3636
callBackUrl: "",
3737
clientId: "not-used",
@@ -84,51 +84,72 @@ class TestBitbucketServerRepositoryProvider {
8484
}
8585

8686
@test async test_getRepo_ok() {
87-
const result = await this.service.getRepo(this.user, "JLDEC", "jldec-repo-march-30");
87+
const result = await this.service.getRepo(this.user, "TES", "2k-repos-1076");
8888
expect(result).to.deep.include({
89-
webUrl: "https://bitbucket.gitpod-self-hosted.com/projects/JLDEC/repos/jldec-repo-march-30",
90-
cloneUrl: "https://bitbucket.gitpod-self-hosted.com/scm/jldec/jldec-repo-march-30.git",
89+
webUrl: "https://bitbucket.gitpod-dev.com/projects/TES/repos/2k-repos-1076",
90+
cloneUrl: "https://bitbucket.gitpod-dev.com/scm/tes/2k-repos-1076.git",
9191
});
9292
}
9393

9494
@test async test_getBranch_ok() {
95-
const result = await this.service.getBranch(this.user, "JLDEC", "jldec-repo-march-30", "main");
95+
const result = await this.service.getBranch(this.user, "TES", "2k-repos-0", "frozen/master");
9696
expect(result).to.deep.include({
97-
name: "main",
97+
name: "frozen/master",
98+
commit: {
99+
author: "Admin",
100+
authorAvatarUrl: "https://secure.gravatar.com/avatar/30cfcf1a839db721063f3c812558bf1e.jpg?s=64&d=mm",
101+
authorDate: "2024-09-20T14:21:19.000Z",
102+
commitMessage: "a test push",
103+
sha: "fb6e71e9a26215a37fd940253e3f996224fbfb2a",
104+
},
98105
});
99106
}
100107

101108
@test async test_getBranches_ok() {
102-
const result = await this.service.getBranches(this.user, "JLDEC", "jldec-repo-march-30");
109+
const result = await this.service.getBranches(this.user, "TES", "2k-repos-0");
103110
expect(result.length).to.be.gte(1);
104111
expect(result[0]).to.deep.include({
105-
name: "main",
112+
name: "master",
106113
});
107114
}
108115

109116
@test async test_getBranches_ok_2() {
110-
try {
111-
await this.service.getBranches(this.user, "mil", "gitpod-large-image");
112-
expect.fail("this should not happen while 'mil/gitpod-large-image' has NO default branch configured.");
113-
} catch (error) {
114-
expect(error.message).to.include(
115-
"refs/heads/master is set as the default branch, but this branch does not exist",
116-
);
117-
}
117+
const response = await this.service.getBranches(this.user, "TES", "2k-repos-1076");
118+
expect(response.length).to.eq(0);
119+
}
120+
121+
@test async test_getCommitHistory_ok() {
122+
const revision = "2781809c095c8cf53c60a524499a9a74649ab506";
123+
const result = await this.service.getCommitHistory(this.user, "filip", "spring-petclinic", revision, 100);
124+
// the unwritten rule is that the revision is not included in the result
125+
// where needed, the caller can add it to the result artificially
126+
// see for example getCommitHistoryForContext in src/prebuilds/incremental-workspace-service.ts
127+
expect(result).to.not.deep.include(revision);
128+
expect(result.length).to.equal(16);
118129
}
119130

120131
@test async test_getCommitInfo_ok() {
121-
const result = await this.service.getCommitInfo(this.user, "JLDEC", "jldec-repo-march-30", "test");
122-
expect(result).to.deep.include({
123-
author: "Alex Tugarev",
124-
});
132+
const result = await this.service.getCommitInfo(
133+
this.user,
134+
"TES",
135+
"2k-repos-0",
136+
"fb6e71e9a26215a37fd940253e3f996224fbfb2a",
137+
);
138+
expect(result).to.not.be.undefined;
139+
expect(result?.author).to.equal("Admin");
140+
}
141+
142+
@test async test_getCommitInfo_ok_2() {
143+
const result = await this.service.getCommitInfo(this.user, "TES", "2k-repos-0", "frozen/master");
144+
expect(result).to.not.be.undefined;
145+
expect(result?.author).to.equal("Admin");
125146
}
126147

127148
@test async test_getUserRepos_ok() {
128149
const result = await this.service.getUserRepos(this.user);
129-
expect(result).to.contain({
130-
url: "https://7990-alextugarev-bbs-6v0gqcpgvj7.ws-eu102.gitpod.io/scm/~alex.tugarev/user.repo.git",
131-
name: "user.repo",
150+
expect(result).to.deep.include({
151+
url: "https://bitbucket.gitpod-dev.com/scm/tes/2k-repos-1076.git",
152+
name: "2k-repos-1076",
132153
});
133154
}
134155
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class BitbucketServerRepositoryProvider implements RepositoryProvider {
194194
});
195195

196196
const commits = commitsResult.values || [];
197-
return commits.map((c) => c.id);
197+
return commits.map((c) => c.id).slice(1);
198198
}
199199

200200
public async searchRepos(user: User, searchString: string, limit: number): Promise<RepositoryInfo[]> {

0 commit comments

Comments
 (0)