-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fd3e3e
commit 0b51cef
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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, | ||
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' | ||
) | ||
}) | ||
}) |