Skip to content

Commit

Permalink
test: Corrected expected mix output
Browse files Browse the repository at this point in the history
Fixes #243
  • Loading branch information
TriPSs committed Dec 28, 2023
1 parent 751a380 commit 4b2aeca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ jobs:
uses: ./
env:
ENV: "dont-use-git"
EXPECTED_TAG: "v0.10.0"
EXPECTED_TAG: "v0.2.0"
with:
github-token: ${{ secrets.github_token }}
version-file: "mix.exs"
Expand All @@ -504,7 +504,7 @@ jobs:
run: node ./test-output.js
env:
FILES: "mix.exs"
EXPECTED_VERSION: "0.10.0"
EXPECTED_VERSION: "0.2.0"

test-toml:
runs-on: ubuntu-latest
Expand Down
2 changes: 0 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23916,8 +23916,6 @@ module.exports = class Mix extends BaseVersioning {
throw new Error(`Failed to extract mix project version.`)
}

console.log(this.oldVersion)

this.newVersion = await bumpVersion(
releaseType,
this.oldVersion
Expand Down
17 changes: 13 additions & 4 deletions test-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const actionConfig = yaml.parse(fs.readFileSync('./action.yml', 'utf8'))
const {
FILES = actionConfig.inputs['version-file'].default,
EXPECTED_VERSION_PATH = actionConfig.inputs['version-path'].default,
EXPECTED_VERSION = actionConfig.inputs['fallback-version'].default,
EXPECTED_VERSION = actionConfig.inputs['fallback-version'].default
} = process.env

assert.ok(FILES, 'Files not defined!')
Expand Down Expand Up @@ -41,8 +41,12 @@ FILES.split(',').map((file, index) => {
parsedContent = toml.parse(fileContent)
break

case 'mix':
parsedContent = fileContent
break

default:
assert.fail('File extension not supported!')
assert.fail(`File extension "${fileExtension}" is not supported!`)
}

console.log(`"${file}" has a valid extension "${fileExtension.toLowerCase()}"`)
Expand All @@ -51,13 +55,18 @@ FILES.split(',').map((file, index) => {

console.log(`"${file}" has valid content`, parsedContent)

const newVersionInFile = objectPath.get(parsedContent, EXPECTED_VERSION_PATH, null)

const expectedVersions = EXPECTED_VERSION.split(',')
const expectedVersion = expectedVersions.length > 0
? expectedVersions[index]
: expectedVersions

if (fileExtension.toLowerCase() === 'mix') {
assert.strictEqual(parsedContent.includes(expectedVersion), true, 'Version does not match what is expected')
return
}

const newVersionInFile = objectPath.get(parsedContent, EXPECTED_VERSION_PATH, null)

console.log(`"${file}" check if "${newVersionInFile}" matches what is expected "${expectedVersion.trim()}"`)

assert.strictEqual(newVersionInFile, expectedVersion.trim(), 'Version does not match what is expected')
Expand Down

0 comments on commit 4b2aeca

Please sign in to comment.