-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mappings with versions are working now!
- Org rule files are broken still - Documentation still needs to be updated
- Loading branch information
1 parent
e0643a3
commit bf9c994
Showing
10 changed files
with
887 additions
and
591 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
__tests__/lib/__snapshots__/fieldMappings-schema.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`constants convenienceFields 1`] = ` | ||
[ | ||
"email", | ||
"slack", | ||
"repo", | ||
"opsgenie", | ||
"pagerduty", | ||
"slack-support-channel", | ||
] | ||
`; | ||
|
||
exports[`constants mappings 1`] = ` | ||
{ | ||
"application": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"contacts": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"description": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"docs": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"integrations": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"lifecycle": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"links": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"repos": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"schema-version": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"service-name": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"tags": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"team": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
"tier": { | ||
"v2": [Function], | ||
"v2.1": [Function], | ||
}, | ||
} | ||
`; | ||
|
||
exports[`constants schemaFields 1`] = ` | ||
[ | ||
"schema-version", | ||
"service-name", | ||
"team", | ||
"contacts", | ||
"tags", | ||
"links", | ||
"integrations", | ||
"docs", | ||
"repos", | ||
"application", | ||
"description", | ||
"tier", | ||
"lifecycle", | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
/** | ||
* @fileoverview This test covers all of the field mappings across versions. | ||
**/ | ||
|
||
const core = require('@actions/core') | ||
const { | ||
mappings, | ||
convenienceFields, | ||
schemaFields, | ||
mapField, | ||
} = require('../../lib/fieldMappings') | ||
|
||
describe.each([ | ||
{ | ||
version: 'v2', | ||
field: 'email', | ||
input: 'testing@manchicken.io', | ||
doc: {}, | ||
value: { | ||
contacts: [{ type: 'email', contact: 'testing@manchicken.io' }], | ||
}, | ||
}, | ||
{ | ||
version: 'v2', | ||
field: 'email', | ||
input: 'testing@manchicken.io', | ||
doc: { | ||
contacts: [ | ||
{ | ||
name: 'test', | ||
type: 'slack', | ||
contact: 'https://my-org.slack.com/archives/my-channel', | ||
}, | ||
], | ||
}, | ||
value: { | ||
contacts: [ | ||
{ | ||
name: 'test', | ||
type: 'slack', | ||
contact: 'https://my-org.slack.com/archives/my-channel', | ||
}, | ||
{ type: 'email', contact: 'testing@manchicken.io' }, | ||
], | ||
}, | ||
}, | ||
{ | ||
version: 'v2.1', | ||
field: 'email', | ||
input: 'testing@manchicken.io', | ||
doc: { | ||
contacts: [ | ||
{ | ||
name: 'test', | ||
type: 'slack', | ||
contact: 'https://my-org.slack.com/archives/my-channel', | ||
}, | ||
], | ||
}, | ||
value: { | ||
contacts: [ | ||
{ | ||
name: 'test', | ||
type: 'slack', | ||
contact: 'https://my-org.slack.com/archives/my-channel', | ||
}, | ||
{ type: 'email', contact: 'testing@manchicken.io' }, | ||
], | ||
}, | ||
}, | ||
{ | ||
version: 'v2', | ||
field: 'slack', | ||
input: 'https://my-org.slack.com/archives/my-channel', | ||
doc: {}, | ||
value: { | ||
contacts: [ | ||
{ | ||
type: 'slack', | ||
contact: 'https://my-org.slack.com/archives/my-channel', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
version: 'v2', | ||
field: 'slack', | ||
input: 'https://my-org.slack.com/archives/my-channel', | ||
doc: { | ||
contacts: [{ type: 'email', contact: 'testing@manchicken.io' }], | ||
}, | ||
value: { | ||
contacts: [ | ||
{ type: 'email', contact: 'testing@manchicken.io' }, | ||
{ | ||
type: 'slack', | ||
contact: 'https://my-org.slack.com/archives/my-channel', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
version: 'v2.1', | ||
field: 'slack', | ||
input: 'https://my-org.slack.com/archives/my-channel', | ||
doc: { | ||
contacts: [{ type: 'email', contact: 'testing@manchicken.io' }], | ||
}, | ||
value: { | ||
contacts: [ | ||
{ type: 'email', contact: 'testing@manchicken.io' }, | ||
{ | ||
type: 'slack', | ||
contact: 'https://my-org.slack.com/archives/my-channel', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
version: 'v2', | ||
field: 'opsgenie', | ||
input: | ||
'https://www.opsgenies.com/service/123e4567-e89b-12d3-a456-426614174000', | ||
doc: { | ||
contacts: [{ type: 'email', contact: 'testing@manchicken.io' }], | ||
}, | ||
value: { | ||
contacts: [{ type: 'email', contact: 'testing@manchicken.io' }], | ||
integrations: { | ||
opsgenie: { | ||
'service-url': | ||
'https://www.opsgenies.com/service/123e4567-e89b-12d3-a456-426614174000', | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
version: 'v2.1', | ||
field: 'opsgenie', | ||
input: | ||
'https://www.opsgenies.com/service/123e4567-e89b-12d3-a456-426614174000', | ||
doc: { | ||
contacts: [{ type: 'email', contact: 'testing@manchicken.io' }], | ||
}, | ||
value: { | ||
contacts: [{ type: 'email', contact: 'testing@manchicken.io' }], | ||
integrations: { | ||
opsgenie: { | ||
'service-url': | ||
'https://www.opsgenies.com/service/123e4567-e89b-12d3-a456-426614174000', | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
version: 'v2', | ||
field: 'pagerduty', | ||
input: 'https://my-org.pagerduty.com/service-directory/PMyService', | ||
doc: { | ||
integrations: { | ||
opsgenie: { | ||
'service-url': | ||
'https://www.opsgenies.com/service/123e4567-e89b-12d3-a456-426614174000', | ||
}, | ||
}, | ||
}, | ||
value: { | ||
integrations: { | ||
opsgenie: { | ||
'service-url': | ||
'https://www.opsgenies.com/service/123e4567-e89b-12d3-a456-426614174000', | ||
}, | ||
pagerduty: 'https://my-org.pagerduty.com/service-directory/PMyService', | ||
}, | ||
}, | ||
}, | ||
{ | ||
version: 'v2.1', | ||
field: 'pagerduty', | ||
input: 'https://my-org.pagerduty.com/service-directory/PMyService', | ||
doc: { | ||
integrations: { | ||
opsgenie: { | ||
'service-url': | ||
'https://www.opsgenies.com/service/123e4567-e89b-12d3-a456-426614174000', | ||
}, | ||
}, | ||
}, | ||
value: { | ||
integrations: { | ||
opsgenie: { | ||
'service-url': | ||
'https://www.opsgenies.com/service/123e4567-e89b-12d3-a456-426614174000', | ||
}, | ||
pagerduty: { | ||
'service-url': | ||
'https://my-org.pagerduty.com/service-directory/PMyService', | ||
}, | ||
}, | ||
}, | ||
}, | ||
])('$field:$version', ({ version, field, input, doc, value }) => { | ||
beforeEach(() => { | ||
core.setFailed.mockClear() | ||
}) | ||
test('mapping', () => { | ||
expect(mapField(field, version)(input, doc)).toEqual(value) | ||
}) | ||
}) |
Oops, something went wrong.