-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from OctopusDeploy/fix-273
feat: added SemVer support and fixed #273
- Loading branch information
Showing
8 changed files
with
1,334 additions
and
4,063 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
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,88 @@ | ||
import {OctopusCLIVersionFetcher} from '../src/octopusCLIVersionFetcher' | ||
|
||
describe('OctopusCLIVersionFetcher tests', () => { | ||
test('Gets latest', () => { | ||
const fetcher = new OctopusCLIVersionFetcher(['1.0.0', '2.0.0', '2.1.0']) | ||
|
||
const version = fetcher.getVersion('*') | ||
|
||
expect(version).toBe('2.1.0') | ||
}) | ||
|
||
test('Fixed returns fixed version', () => { | ||
const fetcher = new OctopusCLIVersionFetcher(['1.0.0', '2.0.0', '2.1.0']) | ||
|
||
const version = fetcher.getVersion('1.0.0') | ||
|
||
expect(version).toBe('1.0.0') | ||
}) | ||
|
||
test('When version no exists', () => { | ||
const fetcher = new OctopusCLIVersionFetcher(['1.0.0', '2.0.0', '2.1.0']) | ||
|
||
expect(() => fetcher.getVersion('5.0.0')).toThrow() | ||
}) | ||
|
||
test('Get latest minor', () => { | ||
const fetcher = new OctopusCLIVersionFetcher([ | ||
'1.0.0', | ||
'2.0.0', | ||
'2.1.0', | ||
'3.0.0' | ||
]) | ||
|
||
const version = fetcher.getVersion('2.*') | ||
|
||
expect(version).toBe('2.1.0') | ||
}) | ||
|
||
test('Get latest patch', () => { | ||
const fetcher = new OctopusCLIVersionFetcher([ | ||
'1.0.0', | ||
'1.0.3', | ||
'2.1.0', | ||
'3.0.0' | ||
]) | ||
|
||
const version = fetcher.getVersion('1.0.*') | ||
|
||
expect(version).toBe('1.0.3') | ||
}) | ||
|
||
test('When version spec if invalid', () => { | ||
const fetcher = new OctopusCLIVersionFetcher(['1.0.0', '2.0.0', '2.1.0']) | ||
|
||
expect(() => fetcher.getVersion('*.*')).toThrow() | ||
|
||
expect(() => fetcher.getVersion('*.2')).toThrow() | ||
|
||
expect(() => fetcher.getVersion('sdfs')).toThrow() | ||
}) | ||
|
||
test('Get latest major', () => { | ||
const fetcher = new OctopusCLIVersionFetcher([ | ||
'1.0.0', | ||
'2.0.0', | ||
'2.1.0', | ||
'3.0.0' | ||
]) | ||
|
||
const version = fetcher.getVersion('2') | ||
|
||
expect(version).toBe('2.1.0') | ||
}) | ||
|
||
test('Get latest not pre-release', () => { | ||
const fetcher = new OctopusCLIVersionFetcher([ | ||
'1.0.0', | ||
'1.0.3', | ||
'2.1.0', | ||
'3.0.0', | ||
'4.0.0-pre' | ||
]) | ||
|
||
const version = fetcher.getVersion('*') | ||
|
||
expect(version).toBe('3.0.0') | ||
}) | ||
}) |
Oops, something went wrong.