Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsciple committed Mar 10, 2020
1 parent eb22d79 commit ba318a1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions __test__/git-auth-helper.test.ts
Expand Up @@ -2,10 +2,12 @@ import * as core from '@actions/core'
import * as fs from 'fs'
import * as gitAuthHelper from '../lib/git-auth-helper'
import * as io from '@actions/io'
import * as os from 'os'
import * as path from 'path'
import {IGitCommandManager} from '../lib/git-command-manager'
import {IGitSourceSettings} from '../lib/git-source-settings'

const isWindows = process.platform === 'win32'
const testWorkspace = path.join(__dirname, '_temp', 'git-auth-helper')
const originalRunnerTemp = process.env['RUNNER_TEMP']
const originalHome = process.env['HOME']
Expand All @@ -22,7 +24,7 @@ describe('git-auth-helper tests', () => {
beforeAll(async () => {
// SSH
sshPath = await io.which('ssh')

// Clear test workspace
await io.rmRF(testWorkspace)
})
Expand Down Expand Up @@ -112,7 +114,8 @@ describe('git-auth-helper tests', () => {
}
)

const configureAuth_copiesUserKnownHosts = 'configureAuth copies user known hosts'
const configureAuth_copiesUserKnownHosts =
'configureAuth copies user known hosts'
it(configureAuth_copiesUserKnownHosts, async () => {
if (!sshPath) {
process.stdout.write(
Expand Down Expand Up @@ -210,7 +213,7 @@ describe('git-auth-helper tests', () => {
)

// Asserty git config
const gitConfigLines = (await fs.promises.readFile(gitConfigPath))
const gitConfigLines = (await fs.promises.readFile(localGitConfigPath))
.toString()
.split('\n')
.filter(x => x)
Expand Down Expand Up @@ -462,7 +465,7 @@ describe('git-auth-helper tests', () => {
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
await authHelper.configureAuth()
let gitConfigContent = (
await fs.promises.readFile(gitConfigPath)
await fs.promises.readFile(localGitConfigPath)
).toString()
expect(gitConfigContent.indexOf('core.sshCommand')).toBeGreaterThanOrEqual(
0
Expand All @@ -478,7 +481,7 @@ describe('git-auth-helper tests', () => {
await authHelper.removeAuth()

// Assert git config
gitConfigContent = (await fs.promises.readFile(gitConfigPath)).toString()
gitConfigContent = (await fs.promises.readFile(localGitConfigPath)).toString()
expect(gitConfigContent.indexOf('core.sshCommand')).toBeLessThan(0)

// Assert SSH key file
Expand Down Expand Up @@ -681,4 +684,4 @@ async function getActualSshKnownHostsPath(): Promise<string> {
expect(actualTempFiles[1].endsWith('_known_hosts')).toBeTruthy()
expect(actualTempFiles[1].startsWith(actualTempFiles[0])).toBeTruthy()
return actualTempFiles[1]
}
}

0 comments on commit ba318a1

Please sign in to comment.