-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for the update bundle filename regex. Signed-off-by: Markus Tacker <[email protected]>
- Loading branch information
1 parent
ca78ae5
commit 918299f
Showing
4 changed files
with
65 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const nameRegEx = (version) => | ||
new RegExp( | ||
`^hello\.nrfcloud\.com-${version}(\\+(?<configuration>[0-9A-Za-z.]+))?-thingy91x-nrf91-update-signed\.bin$` | ||
); |
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,34 @@ | ||
import { nameRegEx } from "./nameRegEx.mjs"; | ||
import assert from "node:assert/strict"; | ||
import { describe, it } from "node:test"; | ||
|
||
describe("nameRegEx", () => { | ||
it("should match a valid filename without configuration", () => | ||
assert.ok( | ||
nameRegEx("1.0.0").test( | ||
"hello.nrfcloud.com-1.0.0-thingy91x-nrf91-update-signed.bin" | ||
) | ||
)); | ||
|
||
it("should match a valid filename with configuration", () => | ||
assert.ok( | ||
nameRegEx("1.0.0").test( | ||
"hello.nrfcloud.com-1.0.0+debug-thingy91x-nrf91-update-signed.bin" | ||
) | ||
)); | ||
|
||
it("should not match an invalid filename", () => { | ||
const version = "1.0.0"; | ||
const regex = nameRegEx(version); | ||
const filename = "invalid-filename.bin"; | ||
assert.ok(!regex.test(filename)); | ||
}); | ||
|
||
it("should not match a filename with a different version", () => { | ||
const version = "1.0.0"; | ||
const regex = nameRegEx(version); | ||
const filename = | ||
"hello.nrfcloud.com-2.0.0-thingy91x-nrf91-update-signed.bin"; | ||
assert.ok(!regex.test(filename)); | ||
}); | ||
}); |
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,23 @@ | ||
name: Publish Firmware Bundles Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
|
||
- name: Run tests | ||
run: node --test ./.github/workflows/**/*.test.mjs |
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