-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: newest release was not considered larger than a beta release
- Loading branch information
1 parent
189f354
commit 9817d3d
Showing
11 changed files
with
235 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,52 @@ | ||
[ | ||
{ | ||
"name": "v1.0.0-beta.1", | ||
"prerelease": true, | ||
"assets": [ | ||
{ | ||
"label": "node distribution", | ||
"browser_download_url": "some_url" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "v1.0.0-beta.2", | ||
"prerelease": true, | ||
"assets": [ | ||
{ | ||
"label": "node distribution", | ||
"browser_download_url": "some_url" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "v1.0.0-beta.3", | ||
"prerelease": true, | ||
"assets": [ | ||
{ | ||
"label": "node distribution", | ||
"browser_download_url": "some_url" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "v1.0.0", | ||
"prerelease": false, | ||
"assets": [ | ||
{ | ||
"label": "node distribution", | ||
"browser_download_url": "some_url" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "v1.1.0-beta.1", | ||
"prerelease": false, | ||
"assets": [ | ||
{ | ||
"label": "node distribution", | ||
"browser_download_url": "some_url" | ||
} | ||
] | ||
} | ||
] |
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,42 @@ | ||
[ | ||
{ | ||
"name": "v1.0.0-beta.1", | ||
"prerelease": true, | ||
"assets": [ | ||
{ | ||
"label": "node distribution", | ||
"browser_download_url": "some_url" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "v1.0.0-beta.2", | ||
"prerelease": true, | ||
"assets": [ | ||
{ | ||
"label": "node distribution", | ||
"browser_download_url": "some_url" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "v1.0.0-beta.3", | ||
"prerelease": true, | ||
"assets": [ | ||
{ | ||
"label": "node distribution", | ||
"browser_download_url": "some_url" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "v1.0.0", | ||
"prerelease": false, | ||
"assets": [ | ||
{ | ||
"label": "node distribution", | ||
"browser_download_url": "some_url" | ||
} | ||
] | ||
} | ||
] |
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,38 @@ | ||
import nock from 'nock'; | ||
|
||
import releases from './data/releases.json'; | ||
import releasesBeta from './data/releases-newest-is-beta.json'; | ||
import { GithubModule } from '../../src/github/github.module'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import { GithubService } from '../../src/github/github.service'; | ||
|
||
describe('GitHub Service', () => { | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
nock.cleanAll(); | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [GithubModule], | ||
}).compile(); | ||
|
||
app = moduleFixture.createNestApplication(); | ||
await app.init(); | ||
}); | ||
|
||
it('should return correct latest release version if there is no older beta release', async () => { | ||
nock('https://api.github.com/').get('/repos/cbartel/nw-company-tool/releases').reply(200, JSON.stringify(releases)); | ||
const githubService = app.get(GithubService); | ||
const latestBetaRelease = await githubService.getLatestBetaRelease(); | ||
expect(latestBetaRelease.name).toEqual('v1.0.0'); | ||
}); | ||
|
||
it('should return correct latest beta release version', async () => { | ||
nock('https://api.github.com/') | ||
.get('/repos/cbartel/nw-company-tool/releases') | ||
.reply(200, JSON.stringify(releasesBeta)); | ||
const githubService = app.get(GithubService); | ||
const latestBetaRelease = await githubService.getLatestBetaRelease(); | ||
expect(latestBetaRelease.name).toEqual('v1.1.0-beta.1'); | ||
}); | ||
}); |
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,17 @@ | ||
{ | ||
"moduleFileExtensions": [ | ||
"js", | ||
"json", | ||
"ts" | ||
], | ||
"rootDir": ".", | ||
"testEnvironment": "node", | ||
"testRegex": "\\.e2e-spec\\.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
}, | ||
"moduleNameMapper": { | ||
"@nw-company-tool/model/(.*)": "<rootDir>/../libs/model/src/$1", | ||
"@nw-company-tool/model": "<rootDir>/../libs/model/src" | ||
} | ||
} |
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
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 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": [ "test", "**/*spec.ts"] | ||
} |