-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
177 additions
and
38 deletions.
There are no files selected for viewing
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
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,20 @@ | ||
enum ActionError { | ||
ACTION_CONTEXT_ERROR = 'This action should only be used in a release context or when creating a new tag or branch', | ||
ACTION_SEMVER_ERROR = 'This action can only operate on semantically versioned tags\nSee: https://semver.org/', | ||
ACTION_OLDREF_ERROR = 'Nothing to do because ref id is earlier than major tag commit', | ||
} | ||
|
||
type ActionErrorObj = { [key in keyof typeof ActionError]: (typeof ActionError)[key] }; | ||
type ActionErrorRevObj = { | ||
[key in keyof typeof ActionError as ActionErrorObj[key]]: key; | ||
}; | ||
|
||
export const ActionErrorMap = { | ||
...ActionError, | ||
...Object.keys(ActionError).reduce((acc, key: keyof typeof ActionError) => { | ||
(acc as any)[ActionError[key]] = key; | ||
return acc; | ||
}, {} as ActionErrorRevObj), | ||
} as const; | ||
|
||
export default ActionError; |
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
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
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 |
---|---|---|
@@ -1,3 +1,23 @@ | ||
test('placeholder', () => { | ||
expect(true).toBeTruthy(); | ||
import ActionError from '@actionstagger/errors'; | ||
|
||
test('Action does not run if event is not public push or release', async () => { | ||
await import('@actionstagger/functions/public').then(({ default: functions }) => { | ||
jest.spyOn(functions, 'isPublicRefPush').mockReturnValue(false); | ||
jest.spyOn(functions, 'isPublishedRelease').mockReturnValue(false); | ||
jest.spyOn(functions, 'isEditedRelease').mockReturnValue(false); | ||
}); | ||
|
||
await import('@actionstagger/main').then(async ({ default: main }) => { | ||
await expect(main()).rejects.toThrow(ActionError.ACTION_CONTEXT_ERROR); | ||
}); | ||
}); | ||
|
||
test('Action does not run if ref does not match semver', async () => { | ||
await import('@actionstagger/functions/public').then(({ default: functions }) => { | ||
jest.spyOn(functions, 'isPublicRefPush').mockReturnValue(true); | ||
jest.spyOn(functions, 'isSemVersionedRef').mockReturnValue(false); | ||
}); | ||
await import('@actionstagger/main').then(async ({ default: main }) => { | ||
await expect(main()).rejects.toThrow(ActionError.ACTION_SEMVER_ERROR); | ||
}); | ||
}); |
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