From d69da85a270e9c19351699b722e35b33eda407af Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Thu, 8 Oct 2020 08:02:21 -0400 Subject: [PATCH] Add a test for when token is passed in --- .../scaffolder/stages/prepare/github.test.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.test.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.test.ts index 4409d815b5..babdd65c04 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.test.ts @@ -90,7 +90,6 @@ describe('GitHubPreparer', () => { {}, ); }); - it('return the temp directory with the path to the folder if it is specified', async () => { const preparer = new GithubPreparer(); mockEntity.spec.path = './template/test/1/2/3'; @@ -100,4 +99,20 @@ describe('GitHubPreparer', () => { /\/template\/test\/1\/2\/3$/, ); }); + it('calls the clone command with the token when provided', async () => { + const preparer = new GithubPreparer({ token: 'abc' }); + await preparer.prepare(mockEntity); + expect(mocks.Clone.clone).toHaveBeenNthCalledWith( + 1, + 'https://github.com/benjdlambert/backstage-graphql-template', + expect.any(String), + { + fetchOpts: { + callbacks: { + credentials: expect.any(Function), + }, + }, + }, + ); + }); });