upload
Some checks failed
Check dist / check-dist (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Licensed / Check licenses (push) Has been cancelled
Build and Test / build (push) Has been cancelled
Build and Test / test (macos-latest) (push) Has been cancelled
Build and Test / test (ubuntu-latest) (push) Has been cancelled
Build and Test / test (windows-latest) (push) Has been cancelled
Build and Test / test-proxy (push) Has been cancelled
Build and Test / test-bypass-proxy (push) Has been cancelled
Build and Test / test-git-container (push) Has been cancelled
Some checks failed
Check dist / check-dist (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Licensed / Check licenses (push) Has been cancelled
Build and Test / build (push) Has been cancelled
Build and Test / test (macos-latest) (push) Has been cancelled
Build and Test / test (ubuntu-latest) (push) Has been cancelled
Build and Test / test (windows-latest) (push) Has been cancelled
Build and Test / test-proxy (push) Has been cancelled
Build and Test / test-bypass-proxy (push) Has been cancelled
Build and Test / test-git-container (push) Has been cancelled
This commit is contained in:
commit
cf328a18c9
101 changed files with 53369 additions and 0 deletions
59
__test__/url-helper.test.ts
Normal file
59
__test__/url-helper.test.ts
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import * as urlHelper from '../lib/url-helper'
|
||||
|
||||
import {IGitSourceSettings} from '../lib/git-source-settings'
|
||||
|
||||
function getSettings(u: string): IGitSourceSettings {
|
||||
return {
|
||||
githubServerUrl: u,
|
||||
repositoryPath: '',
|
||||
repositoryOwner: 'some-owner',
|
||||
repositoryName: 'some-name',
|
||||
ref: '',
|
||||
commit: '',
|
||||
clean: false,
|
||||
filter: undefined,
|
||||
sparseCheckout: [],
|
||||
sparseCheckoutConeMode: false,
|
||||
fetchDepth: 0,
|
||||
fetchTags: false,
|
||||
showProgress: false,
|
||||
lfs: false,
|
||||
submodules: false,
|
||||
nestedSubmodules: false,
|
||||
authToken: '',
|
||||
sshKey: '',
|
||||
sshKnownHosts: '',
|
||||
sshStrict: false,
|
||||
sshUser: '',
|
||||
persistCredentials: false,
|
||||
workflowOrganizationId: undefined,
|
||||
setSafeDirectory: false
|
||||
}
|
||||
}
|
||||
describe('url-helper tests', () => {
|
||||
it('getFetchUrl works on GitHub repos', async () => {
|
||||
expect(urlHelper.getFetchUrl(getSettings('https://github.com'))).toBe(
|
||||
'https://github.com/some-owner/some-name'
|
||||
)
|
||||
})
|
||||
|
||||
it('getFetchUrl works on 3rd party repos with sub-path', async () => {
|
||||
expect(
|
||||
urlHelper.getFetchUrl(getSettings('https://other.com/subpath'))
|
||||
).toBe('https://other.com/subpath/some-owner/some-name')
|
||||
})
|
||||
|
||||
it('getFetchUrl works on 3rd party repos with ssh keys', async () => {
|
||||
expect(
|
||||
urlHelper.getFetchUrl(getSettings('https://other.com/subpath'))
|
||||
).toBe('https://other.com/subpath/some-owner/some-name')
|
||||
})
|
||||
|
||||
it('getFetchUrl works with ssh credentials', async () => {
|
||||
let settings = getSettings('https://other.com/subpath')
|
||||
settings.sshKey = 'not-empty'
|
||||
expect(urlHelper.getFetchUrl(settings)).toBe(
|
||||
'git@other.com:some-owner/some-name.git'
|
||||
)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue