Skip to content

Commit

Permalink
test: fix tests using app name from inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermelimak committed Nov 10, 2022
1 parent 34acdb9 commit 71e1ece
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26209,6 +26209,7 @@ try {

exports.PR_TITLE_PREFIX = '[OPTIC-RELEASE-AUTOMATION]'
exports.ZIP_EXTENSION = '.zip'
exports.APP_NAME = 'optic-release-automation[bot]'


/***/ }),
Expand Down
1 change: 1 addition & 0 deletions src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

exports.PR_TITLE_PREFIX = '[OPTIC-RELEASE-AUTOMATION]'
exports.ZIP_EXTENSION = '.zip'
exports.APP_NAME = 'optic-release-automation[bot]'
10 changes: 7 additions & 3 deletions test/bump.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ const artifactAction = require('../src/utils/artifact')
const { PR_TITLE_PREFIX } = require('../src/const')

const TEST_VERSION = '3.1.1'
const runSpawnStub = sinon.stub().returns(TEST_VERSION)
const TEST_COMMIT_HASH = 'c86b0a35014a7036b245f81ff9de9bd738a5fe95'
const runSpawnStub = sinon.stub()

runSpawnStub.returns(TEST_VERSION)
runSpawnStub.withArgs('git', ['rev-parse', 'HEAD']).returns(TEST_COMMIT_HASH)

function setup() {
const coreStub = sinon.stub(core)
Expand Down Expand Up @@ -181,7 +185,7 @@ tap.test('should work with a custom version-prefix', async () => {
endpoint: 'release',
body: {
version: TEST_VERSION,
target: branchName,
target: TEST_COMMIT_HASH,
},
},
prData.inputs
Expand All @@ -207,7 +211,7 @@ tap.test('should call the release endpoint with a new version', async () => {
endpoint: 'release',
body: {
version: `v${TEST_VERSION}`,
target: `release/v${TEST_VERSION}`,
target: TEST_COMMIT_HASH,
},
},
DEFAULT_ACTION_DATA.inputs
Expand Down
22 changes: 21 additions & 1 deletion test/release.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const notifyIssuesAction = require('../src/utils/notifyIssues')
const revertCommitAction = require('../src/utils/revertCommit')
const callApiAction = require('../src/utils/callApi')

const { PR_TITLE_PREFIX } = require('../src/const')
const { PR_TITLE_PREFIX, APP_NAME } = require('../src/const')
const actionLog = require('../src/log')

let deleteReleaseStub = sinon.stub().resolves()
Expand All @@ -33,6 +33,7 @@ const DEFAULT_ACTION_DATA = {
},
inputs: {
semver: 'patch',
'app-name': APP_NAME,
},
context: {
eventName: 'pull_request',
Expand Down Expand Up @@ -187,6 +188,7 @@ tap.test('Should publish to npm without optic', async () => {
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
},
})
Expand All @@ -205,6 +207,7 @@ tap.test('Should not publish to npm if there is no npm token', async () => {
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
},
Expand All @@ -218,6 +221,7 @@ tap.test('Should publish to npm with optic', async () => {
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'optic-token': 'optic-token',
},
Expand All @@ -235,6 +239,7 @@ tap.test('Should tag versions', async () => {
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -251,6 +256,7 @@ tap.test('Should call the release method', async () => {
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -268,6 +274,7 @@ tap.test('Should call the release method', async () => {
},
},
{
'app-name': APP_NAME,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -282,6 +289,7 @@ tap.test(
const data = clone(DEFAULT_ACTION_DATA)
data.context.payload.pull_request.merged = false
data.inputs = {
...data.inputs,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -297,6 +305,7 @@ tap.test("Should NOT use npm if the pr wasn't merged", async () => {
const data = clone(DEFAULT_ACTION_DATA)
data.context.payload.pull_request.merged = false
data.inputs = {
...data.inputs,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -310,6 +319,7 @@ tap.test("Should NOT tag version in git if the pr wasn't merged", async () => {
const data = clone(DEFAULT_ACTION_DATA)
data.context.payload.pull_request.merged = false
data.inputs = {
...data.inputs,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand Down Expand Up @@ -351,6 +361,7 @@ tap.test(
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -368,6 +379,7 @@ tap.test('Should call core.setFailed if the release fails', async () => {
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -388,6 +400,7 @@ tap.test(
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -408,6 +421,7 @@ tap.test(
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -426,6 +440,7 @@ tap.test('Should tag the major, minor & patch correctly for 0', async () => {

const data = clone(DEFAULT_ACTION_DATA)
data.inputs = {
...data.inputs,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -448,6 +463,7 @@ tap.test('Should tag the major, minor & patch correctly', async () => {

const data = clone(DEFAULT_ACTION_DATA)
data.inputs = {
...data.inputs,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -472,6 +488,7 @@ tap.test(
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -495,6 +512,7 @@ tap.test(

const data = clone(DEFAULT_ACTION_DATA)
data.inputs = {
...data.inputs,
'npm-token': 'a-token',
'optic-token': 'optic-token',
'sync-semver-tags': 'true',
Expand All @@ -519,6 +537,7 @@ tap.test(
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'notify-linked-issues': 'true',
},
Expand All @@ -542,6 +561,7 @@ tap.test(
await release({
...DEFAULT_ACTION_DATA,
inputs: {
'app-name': APP_NAME,
'npm-token': 'a-token',
'notify-linked-issues': 'false',
},
Expand Down

0 comments on commit 71e1ece

Please sign in to comment.