Skip to content

Commit

Permalink
fix: Modifications to branch protection checks (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevoland authored Feb 19, 2024
2 parents a06fa37 + 6c81591 commit b7004ff
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/mergeDeep.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const mergeBy = require('./mergeArrayBy')
const DeploymentConfig = require('./deploymentConfig')

const NAME_FIELDS = ['name', 'username', 'actor_id', 'login', 'type', 'key_prefix']
const NAME_FIELDS = ['name', 'username', 'actor_id', 'login', 'type', 'key_prefix', 'context']
const NAME_USERNAME_PROPERTY = item => NAME_FIELDS.find(prop => Object.prototype.hasOwnProperty.call(item, prop))
const GET_NAME_USERNAME_PROPERTY = item => { if (NAME_USERNAME_PROPERTY(item)) return item[NAME_USERNAME_PROPERTY(item)] }

Expand Down
68 changes: 67 additions & 1 deletion test/unit/lib/mergeDeep.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ entries:
//console.log(`diffs ${JSON.stringify(merged, null, 2)}`)
})

it('Has changes with additions to arrays', () => {
it('Has changes with additions to branch protection checks', () => {
const target = {
branches: [
{
Expand Down Expand Up @@ -1379,4 +1379,70 @@ entries:
const changes = mergeDeep.compareDeep(target, source)
expect(changes).toEqual(expected)
})

it('Has modifications to branch protection checks', () => {
const target = {
branches: [
{
name: 'master',
protection: {
required_status_checks: {
strict: true,
checks: [{
context: 'test1',
app_id: '123'
}],
}
}
}
]
}

const source = {
branches: [
{
name: 'master',
protection: {
required_status_checks: {
strict: true,
checks: [{
context: 'test1',
app_id: '345'
}],
}
}
}
]
}

const expected = {
additions: {},
deletions: {},
modifications: {
branches: [
{
name: "master",
protection: {
required_status_checks: {
checks: [{
context: 'test1',
app_id: '345'
}]
},
},
}
]
},
hasChanges: true
}

const ignorableFields = []
const mergeDeep = new MergeDeep(
log,
jest.fn(),
ignorableFields
);
const changes = mergeDeep.compareDeep(target, source)
expect(changes).toEqual(expected)
})
})

0 comments on commit b7004ff

Please sign in to comment.