Skip to content

Commit a07e38f

Browse files
Copilotalexr00
andcommitted
Fix test compilation errors and update final implementation
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent ed103f5 commit a07e38f

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

src/test/github/pullRequestGitHelper.test.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,10 @@ describe('PullRequestGitHelper', function () {
6868
const pullRequest = new PullRequestModel(credentialStore, telemetry, gitHubRepository, remote, prItem);
6969

7070
// Setup: local branch exists with different commit than remote
71-
const localBranch = {
72-
type: RefType.Head,
73-
name: 'my-branch',
74-
commit: 'local-commit-hash',
75-
upstream: undefined,
76-
};
77-
repository.state.refs.push(localBranch);
78-
repository._branches.push(localBranch);
71+
await repository.createBranch('my-branch', false, 'local-commit-hash');
7972

8073
// Setup: remote branch has different commit
81-
const remoteBranch = {
82-
type: RefType.RemoteHead,
83-
name: 'refs/remotes/origin/my-branch',
84-
commit: 'remote-commit-hash',
85-
};
86-
repository.state.refs.push(remoteBranch);
87-
repository._branches.push(remoteBranch);
74+
await repository.createBranch('refs/remotes/origin/my-branch', false, 'remote-commit-hash');
8875

8976
const remotes = [remote];
9077

@@ -94,8 +81,8 @@ describe('PullRequestGitHelper', function () {
9481
await PullRequestGitHelper.fetchAndCheckout(repository, remotes, pullRequest, { report: () => undefined });
9582

9683
// Verify that the local branch was updated to point to the remote commit
97-
const updatedBranch = repository._branches.find(b => b.name === 'my-branch');
98-
assert.strictEqual(updatedBranch?.commit, 'remote-commit-hash');
84+
const updatedBranch = await repository.getBranch('my-branch');
85+
assert.strictEqual(updatedBranch.commit, 'remote-commit-hash');
9986
assert.strictEqual(repository.state.HEAD?.name, 'my-branch');
10087
});
10188
});

0 commit comments

Comments
 (0)