-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add integration testing (#131)
* docs: Update description * deps: Add nock * chore: Add resolveJsonModule * test: Add integration testing * chore: Add @typescript-eslint/eslint-plugin * refactor: Fix lint errors * chore: Add eslint-plugin-jest * refactor: Fix lint errors * test: Add remove working files * ci: Comment out cache steps
- Loading branch information
Showing
16 changed files
with
1,249 additions
and
96 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
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 @@ | ||
{"name":"hugo","full_name":"hugo","oldname":null,"aliases":[],"versioned_formulae":[],"desc":"Configurable static site generator","homepage":"https://gohugo.io/","versions":{"stable":"0.62.2","devel":null,"head":"HEAD","bottle":true},"revision":0,"version_scheme":0,"bottle":{"stable":{"rebuild":0,"cellar":":any_skip_relocation","prefix":"/usr/local","root_url":"https://homebrew.bintray.com/bottles","files":{"catalina":{"url":"https://homebrew.bintray.com/bottles/hugo-0.62.2.catalina.bottle.tar.gz","sha256":"354545c2c125e01a8860f83577fb4218d585fa8d38cd7f51e4228a149347fbcf"},"mojave":{"url":"https://homebrew.bintray.com/bottles/hugo-0.62.2.mojave.bottle.tar.gz","sha256":"9645b64fe6290c4c3b7591ef21139247f0fad6e49da1edd01665b3130a8f1d1a"},"high_sierra":{"url":"https://homebrew.bintray.com/bottles/hugo-0.62.2.high_sierra.bottle.tar.gz","sha256":"0ede4cbcc7536dd6b05107376637840356062273d734b4106be98b3d1732d50c"}}}},"keg_only":false,"bottle_disabled":false,"options":[],"build_dependencies":["go"],"dependencies":[],"recommended_dependencies":[],"optional_dependencies":[],"uses_from_macos":[],"requirements":[],"conflicts_with":[],"caveats":null,"installed":[],"linked_keg":null,"pinned":false,"outdated":false,"analytics":{"install":{"30d":{"hugo":24278,"hugo --HEAD":30},"90d":{"hugo":68639,"hugo --HEAD":80},"365d":{"hugo":223748,"hugo --HEAD":321}},"install_on_request":{"30d":{"hugo":23621,"hugo --HEAD":27},"90d":{"hugo":66676,"hugo --HEAD":74},"365d":{"hugo":215985,"hugo --HEAD":305}},"build_error":{"30d":{"hugo":0}}}} |
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as main from '../src/main'; | ||
import * as io from '@actions/io'; | ||
import path from 'path'; | ||
import nock from 'nock'; | ||
// import {FetchError} from 'node-fetch'; | ||
import jsonTestBrew from './data/brew.json'; | ||
// import jsonTestGithub from './data/github.json'; | ||
|
||
jest.setTimeout(30000); | ||
const repo = 'hugo'; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
}); | ||
|
||
afterEach(() => { | ||
delete process.env['INPUT_HUGO-VERSION']; | ||
nock.cleanAll(); | ||
}); | ||
|
||
describe('Integration testing run()', () => { | ||
afterEach(async () => { | ||
await io.rmRF(path.join(`${process.env.HOME}`, 'tmp')); | ||
}); | ||
|
||
test('succeed in installing a custom version', async () => { | ||
const testVersion = '0.61.0'; | ||
process.env['INPUT_HUGO-VERSION'] = testVersion; | ||
const result: main.ActionResult = await main.run(); | ||
expect(result.exitcode).toBe(0); | ||
expect(result.output).toMatch(`Hugo Static Site Generator v${testVersion}`); | ||
}); | ||
|
||
test('succeed in installing the latest version', async () => { | ||
const testVersion = 'latest'; | ||
process.env['INPUT_HUGO-VERSION'] = testVersion; | ||
nock('https://formulae.brew.sh') | ||
.get(`/api/formula/${repo}.json`) | ||
.reply(200, jsonTestBrew); | ||
const result: main.ActionResult = await main.run(); | ||
expect(result.exitcode).toBe(0); | ||
expect(result.output).toMatch('Hugo Static Site Generator v0.62.2'); | ||
}); | ||
}); | ||
|
||
describe('showVersion()', () => { | ||
let result: main.ActionResult = { | ||
exitcode: 0, | ||
output: '' | ||
}; | ||
|
||
test('return version', async () => { | ||
result = await main.showVersion('git', ['--version']); | ||
expect(result.exitcode).toBe(0); | ||
expect(result.output).toMatch(/git version/); | ||
}); | ||
|
||
test('return not found', async () => { | ||
result = await main.showVersion('gitgit', ['--version']); | ||
expect(result.exitcode).not.toBe(0); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export enum Tool { | ||
Name = 'Hugo', | ||
Org = 'gohugoio', | ||
Repo = 'hugo', | ||
CmdName = 'hugo', | ||
CmdOptVersion = 'version' | ||
} |
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
Oops, something went wrong.