Skip to content

Commit df0385a

Browse files
committed
test: add more test case
1 parent 1e7ac38 commit df0385a

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

lambda/fota/getNextUpgrade.spec.ts

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import { FOTAJobTarget } from '@hello.nrfcloud.com/proto/hello'
22
import assert from 'node:assert/strict'
3-
import { describe, it } from 'node:test'
3+
import test, { describe, it } from 'node:test'
44
import { getNextUpgrade } from './getNextUpgrade.ts'
55

66
void describe('getNextUpgrade()', () => {
77
void it('should return the next upgrade based on a static version', () =>
88
assert.deepEqual(
99
getNextUpgrade(
10-
{
11-
'2.0.0': 'APP*1e29dfa3*v2.0.1',
12-
'2.0.1': 'APP*cd5412d9*v2.0.2',
13-
},
10+
{ '2.0.0': 'APP*1e29dfa3*v2.0.1', '2.0.1': 'APP*cd5412d9*v2.0.2' },
1411
{
1512
appVersion: '2.0.0',
1613
supportedFOTATypes: [FOTAJobTarget.application],
@@ -26,22 +23,44 @@ void describe('getNextUpgrade()', () => {
2623
},
2724
))
2825

29-
void it('should return the next upgrade based on a range', () =>
26+
void describe('should return the next upgrade based on a range', () => {
27+
for (const range of ['>=1.0.0', '<2.0.1']) {
28+
void test(range, () =>
29+
assert.deepEqual(
30+
getNextUpgrade(
31+
{ [range]: 'APP*1e29dfa3*v2.0.1' },
32+
{
33+
appVersion: '2.0.0',
34+
supportedFOTATypes: [FOTAJobTarget.application],
35+
mfwVersion: '1.3.6',
36+
},
37+
),
38+
{
39+
upgrade: {
40+
reportedVersion: '2.0.0',
41+
bundleId: 'APP*1e29dfa3*v2.0.1',
42+
target: FOTAJobTarget.application,
43+
},
44+
},
45+
),
46+
)
47+
}
48+
})
49+
50+
void it('should return null in case of no upgrade', () =>
3051
assert.deepEqual(
3152
getNextUpgrade(
53+
{ '<2.0.1': 'APP*1e29dfa3*v2.0.1' },
3254
{
33-
'>=1.0.0': 'APP*1e29dfa3*v2.0.1',
34-
},
35-
{
36-
appVersion: '2.0.0',
55+
appVersion: '2.0.1',
3756
supportedFOTATypes: [FOTAJobTarget.application],
3857
mfwVersion: '1.3.6',
3958
},
4059
),
4160
{
4261
upgrade: {
43-
reportedVersion: '2.0.0',
44-
bundleId: 'APP*1e29dfa3*v2.0.1',
62+
reportedVersion: '2.0.1',
63+
bundleId: null,
4564
target: FOTAJobTarget.application,
4665
},
4766
},

0 commit comments

Comments
 (0)