Skip to content

Commit

Permalink
Set up full input testing (r0adkll#150)
Browse files Browse the repository at this point in the history
* Extract main loop to something testable

* Revert "Extract main loop to something testable"

This reverts commit 35a7845.

* Extract code that interacts with Google Play
We can now test our input flow as a whole

* Create some basic tests for `completed` status publishing

* Fix applying inputs
We don't want to be keeping values between runs

* Drop some redundant tests

* Create basic tests for draft rollout

* Run build

* Fix userFraction bug

* Improve readability of initialising inputs

* Fix runUpload mocking

* Migrate to github-action-ts-run-api
  • Loading branch information
boswelja authored Oct 24, 2022
1 parent 4d510d3 commit b84eace
Show file tree
Hide file tree
Showing 7 changed files with 901 additions and 36 deletions.
98 changes: 98 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import {RunOptions, RunTarget} from 'github-action-ts-run-api';

const target = RunTarget.mainJs('action.yml');

async function expectRunInitiatesUpload(options: RunOptions) {
const result = await target.run(options)
expect(result.commands.errors.length).toBe(1)
expect(result.commands.errors).toContainEqual("The incoming JSON object does not contain a client_email field")
}

test("correct inputs for complete rollout", async () => {
// Run with the bare minimum
const minimumOptions = RunOptions.create()
.setInputs({
serviceAccountJsonPlainText: "{}",
packageName: "com.package.name",
releaseFiles: "./__tests__/releasefiles/*.aab",
track: "production",
status: "completed",
})
await expectRunInitiatesUpload(minimumOptions)

// Test with optional extras
const extraOptions = RunOptions.create()
.setInputs({
serviceAccountJsonPlainText: "{}",
packageName: "com.package.name",
releaseFiles: "./__tests__/releasefiles/*.aab",
releaseName: "Release name",
track: "production",
inAppUpdatePriority: "3",
status: "completed",
whatsNewDir: "./__tests__/whatsnew",
changesNotSentForReview: "true",
existingEditId: "123"
})
await expectRunInitiatesUpload(extraOptions)
})

test("correct inputs for inProgress rollout", async () => {
// Run with the bare minimum
const minimumOptions = RunOptions.create()
.setInputs({
serviceAccountJsonPlainText: "{}",
packageName: "com.package.name",
releaseFiles: "./__tests__/releasefiles/*.aab",
track: "production",
userFraction: "0.99",
status: "inProgress",
})
await expectRunInitiatesUpload(minimumOptions)

// Test with optional extras
const extraOptions = RunOptions.create()
.setInputs({
serviceAccountJsonPlainText: "{}",
packageName: "com.package.name",
releaseFiles: "./__tests__/releasefiles/*.aab",
releaseName: "Release name",
track: "production",
inAppUpdatePriority: "3",
userFraction: "0.5",
status: "inProgress",
whatsNewDir: "./__tests__/whatsnew",
changesNotSentForReview: "true",
existingEditId: "123"
})
await expectRunInitiatesUpload(extraOptions)
})

test("correct inputs for draft rollout", async () => {
// Run with the bare minimum
const minimumOptions = RunOptions.create()
.setInputs({
serviceAccountJsonPlainText: "{}",
packageName: "com.package.name",
releaseFiles: "./__tests__/releasefiles/*.aab",
track: "production",
status: "draft",
})
await expectRunInitiatesUpload(minimumOptions)

// Test with optional extras
const extraOptions = RunOptions.create()
.setInputs({
serviceAccountJsonPlainText: "{}",
packageName: "com.package.name",
releaseFiles: "./__tests__/releasefiles/*.aab",
releaseName: "Release name",
track: "production",
inAppUpdatePriority: "3",
status: "draft",
whatsNewDir: "./__tests__/whatsnew",
changesNotSentForReview: "true",
existingEditId: "123"
})
await expectRunInitiatesUpload(extraOptions)
})
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inputs:
required: false
changesNotSentForReview:
description: "Indicates that the changes in this edit will not be reviewed until they are explicitly sent for review from the Google Play Console"
default: false
default: 'false'
required: false
existingEditId:
description: "The ID of an existing edit that has not been completed. If this is supplied, the action will append information to that rather than creating an edit"
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit b84eace

Please sign in to comment.