Skip to content

Commit

Permalink
chore: bump up for @actions/github to v5.0.0 (#63)
Browse files Browse the repository at this point in the history
* test: fix tests to adapt @actions/github v5.0.0

* chore: bump up for @actions/github to v5.0.0

* test: use toThrowError matcher in tests which functions throw error
  • Loading branch information
kentaro-m authored Feb 17, 2023
1 parent 216069a commit beeb0b1
Show file tree
Hide file tree
Showing 9 changed files with 1,064 additions and 1,592 deletions.
699 changes: 384 additions & 315 deletions __tests__/handler.test.ts

Large diffs are not rendered by default.

44 changes: 26 additions & 18 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,20 @@ describe('chooseUsersFromGroups', () => {

describe('fetchConfigurationFile', () => {
test('fetchs the configuration file', async () => {
const client = new github.GitHub('token')

client.repos = {
getContents: jest.fn().mockImplementation(async () => ({
data: {
content:
'IyBTZXQgdG8gdHJ1ZSB0byBhZGQgcmV2aWV3ZXJzIHRvIHB1bGwgcmVxdWVzdHMNCmFkZFJldmlld2VyczogdHJ1ZQ0KDQojIFNldCB0byB0cnVlIHRvIGFkZCBhc3NpZ25lZXMgdG8gcHVsbCByZXF1ZXN0cw0KYWRkQXNzaWduZWVzOiBmYWxzZQ0KDQojIEEgbGlzdCBvZiByZXZpZXdlcnMgdG8gYmUgYWRkZWQgdG8gcHVsbCByZXF1ZXN0cyAoR2l0SHViIHVzZXIgbmFtZSkNCnJldmlld2VyczoNCiAgLSByZXZpZXdlckENCiAgLSByZXZpZXdlckINCiAgLSByZXZpZXdlckM=',
;(github.getOctokit as jest.Mock).mockImplementation(() => ({
rest: {
repos: {
getContent: async () => ({
data: {
content:
'IyBTZXQgdG8gdHJ1ZSB0byBhZGQgcmV2aWV3ZXJzIHRvIHB1bGwgcmVxdWVzdHMNCmFkZFJldmlld2VyczogdHJ1ZQ0KDQojIFNldCB0byB0cnVlIHRvIGFkZCBhc3NpZ25lZXMgdG8gcHVsbCByZXF1ZXN0cw0KYWRkQXNzaWduZWVzOiBmYWxzZQ0KDQojIEEgbGlzdCBvZiByZXZpZXdlcnMgdG8gYmUgYWRkZWQgdG8gcHVsbCByZXF1ZXN0cyAoR2l0SHViIHVzZXIgbmFtZSkNCnJldmlld2VyczoNCiAgLSByZXZpZXdlckENCiAgLSByZXZpZXdlckINCiAgLSByZXZpZXdlckM=',
},
}),
},
})),
} as any
},
}))

const client = github.getOctokit('token')

const config = await fetchConfigurationFile(client, {
owner: 'kentaro-m',
Expand All @@ -214,17 +218,21 @@ describe('fetchConfigurationFile', () => {
})

test('responds with an error if failure to fetch the configuration file', async () => {
const client = new github.GitHub('token')

client.repos = {
getContents: jest.fn().mockImplementation(async () => ({
data: {
content: '',
;(github.getOctokit as jest.Mock).mockImplementation(() => ({
rest: {
repos: {
getContent: async () => ({
data: {
content: '',
},
}),
},
})),
} as any
},
}))

const client = github.getOctokit('token')

expect(
expect(async () =>
fetchConfigurationFile(client, {
owner: 'kentaro-m',
repo: 'auto-assign-action-test',
Expand Down
Loading

0 comments on commit beeb0b1

Please sign in to comment.