diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts new file mode 100644 index 00000000..3cde86de --- /dev/null +++ b/__tests__/git.test.ts @@ -0,0 +1,39 @@ +process.env["INPUT_FOLDER"] = "build"; + +import { execute } from "../src/util"; +import { init } from "../src/git"; +import {action} from '../src/constants' + +jest.mock("../src/constants", () => ({ + build: 'dist', + action: { + pusher: { + name: 'montezuma', + email: 'best@cat', + }, + gitHubToken: 'exists', + } +})); + +jest.mock("../src/util", () => ({ + execute: jest.fn() +})); + +jest.mock("@actions/io", () => ({ + cp: jest.fn() +})); + +describe("git", () => { + describe("init", () => { + it("should execute three commands", async () => { + + await init(); + + expect(execute).toBeCalledTimes(3); + }); + + it("should fail if the dpeloyment folder begins with /", async () => { + // TODO: + }) + }); +}); diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts index 6ec5a28d..7a020b09 100644 --- a/__tests__/util.test.ts +++ b/__tests__/util.test.ts @@ -5,15 +5,19 @@ jest.mock('@actions/exec', () => ({ exec: jest.fn() })) -test('util - execute - should be called with the correct arguements', async() => { - await execute('echo Montezuma', './') - - expect(exec).toBeCalledWith( - "echo Montezuma", [], { - cwd: "./", - listeners: { - stdout: expect.any(Function) - } - } - ) -}); \ No newline at end of file +describe('util', () => { + describe('execute', () => { + it('should be called with the correct arguements', async() => { + await execute('echo Montezuma', './') + + expect(exec).toBeCalledWith( + "echo Montezuma", [], { + cwd: "./", + listeners: { + stdout: expect.any(Function) + } + } + ) + }); + }) +}) \ No newline at end of file diff --git a/src/git.ts b/src/git.ts index 72b102c9..1367d99a 100644 --- a/src/git.ts +++ b/src/git.ts @@ -8,10 +8,7 @@ import { workspace, build, action, repositoryPath } from "./constants"; */ export async function init(): Promise { try { - const accessToken = core.getInput("ACCESS_TOKEN"); - const gitHubToken = core.getInput("GITHUB_TOKEN"); - - if (!accessToken && !gitHubToken) { + if (!action.accessToken && !action.gitHubToken) { core.setFailed( "You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy." );