Skip to content

Commit

Permalink
Revert test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hampus-andersson-op committed Apr 22, 2024
1 parent 8edd7ca commit dc0e35d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/branchprotection/BranchProtectionService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import { Endpoints, RequestError } from '@octokit/types';
import { GitHub } from '@actions/github/lib/utils';
import { Endpoints } from '@octokit/types';
export class BranchProtectionService {
public static async getStateOfBranchProtection(): Promise<void> {
try {
Expand All @@ -11,7 +11,7 @@ export class BranchProtectionService {

const octokit: InstanceType<typeof GitHub> = github.getOctokit(token);
type branchProtectionRepsponse = Endpoints['GET /repos/{owner}/{repo}/branches/{branch}/protection']['response'];
const response: branchProtectionRepsponse | any = await octokit.rest.repos.getBranchProtection({
const response: branchProtectionRepsponse = await octokit.rest.repos.getBranchProtection({
owner,
repo,
branch: 'main',
Expand Down
30 changes: 15 additions & 15 deletions tests/branchprotection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ describe('BranchProtectionService', () => {
expect(warningStub.called).to.be.true;
expect(exportVariableStub.calledWith('numberOfReviewers', 0)).to.be.true;
});
// it('should call warning and set numberOfReviewers to 0 when github repo is private (status = 404)', async () => {
// getOctokitStub.returns({
// rest: {
// repos: {
// getBranchProtection: sinon.stub().rejects({
// status: 404,
// message: 'Branch not protected',
// }),
// },
// },
// });
it('should call warning and set numberOfReviewers to 0 when github repo is private (status = 404)', async () => {
getOctokitStub.returns({
rest: {
repos: {
getBranchProtection: sinon.stub().rejects({
status: 404,
message: 'Branch not protected',
}),
},
},
});

// await BranchProtectionService.getStateOfBranchProtection();
// expect(warningStub.called).to.be.false;
// expect(exportVariableStub.calledWith('numberOfReviewers', 0)).to.be.true;
// });
await BranchProtectionService.getStateOfBranchProtection();
expect(warningStub.called).to.be.false;
expect(exportVariableStub.calledWith('numberOfReviewers', 0)).to.be.true;
});
});

0 comments on commit dc0e35d

Please sign in to comment.