|
9 | 9 | getSshPath, |
10 | 10 | sshKeyscan, |
11 | 11 | setupGitAction, |
12 | | - cleanupGitAction, |
13 | | - TEMPDIR_NAME |
| 12 | + cleanupGitAction |
14 | 13 | } from '../src/setup-git-action' |
15 | 14 |
|
16 | 15 | jest.mock('@actions/core', () => ({ |
@@ -59,8 +58,9 @@ describe('test npm-setup-publish', () => { |
59 | 58 | }) |
60 | 59 |
|
61 | 60 | test('get ssh path', () => { |
62 | | - const filePath = getSshPath('id_rsa') |
63 | | - expect(filePath).toEqual(`${runnerTempDir}/${TEMPDIR_NAME}/id_rsa`) |
| 61 | + const directory = 'some-subdirectory' |
| 62 | + const filePath = getSshPath(directory, 'id_rsa') |
| 63 | + expect(filePath).toEqual(`${runnerTempDir}/${directory}/id_rsa`) |
64 | 64 | }) |
65 | 65 |
|
66 | 66 | test('ssh-keyscan', async () => { |
@@ -89,11 +89,12 @@ describe('test npm-setup-publish', () => { |
89 | 89 | |
90 | 90 | const username = 'Example User' |
91 | 91 | const deployKey = 'definitely an ssh key' |
| 92 | + const directory = 'a-uuid' |
92 | 93 |
|
93 | | - await setupGitAction(email, username, deployKey) |
| 94 | + await setupGitAction(email, username, deployKey, directory) |
94 | 95 |
|
95 | 96 | const sshKeyData = await fs.readFile( |
96 | | - path.join(runnerTempDir as string, TEMPDIR_NAME, 'id_rsa') |
| 97 | + path.join(runnerTempDir as string, directory, 'id_rsa') |
97 | 98 | ) |
98 | 99 | expect(sshKeyData.toString()).toEqual(`${deployKey}\n`) |
99 | 100 |
|
@@ -124,13 +125,14 @@ describe('test npm-setup-publish', () => { |
124 | 125 | }) |
125 | 126 |
|
126 | 127 | test('cleanupGitAction', async () => { |
127 | | - const keyPath = path.join(runnerTempDir as string, TEMPDIR_NAME, 'id_rsa') |
| 128 | + const directory = 'a-uuid' |
| 129 | + const keyPath = path.join(runnerTempDir as string, directory, 'id_rsa') |
128 | 130 | const hostsPath = path.join( |
129 | 131 | runnerTempDir as string, |
130 | | - TEMPDIR_NAME, |
| 132 | + directory, |
131 | 133 | 'known_hosts' |
132 | 134 | ) |
133 | | - await cleanupGitAction() |
| 135 | + await cleanupGitAction(directory) |
134 | 136 |
|
135 | 137 | const mockExec = mocked(exec) |
136 | 138 | expect(mockExec.mock.calls.length).toEqual(6) |
|
0 commit comments