Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
(test) Add test with URL which contains urlencoded_filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducatel committed Jun 6, 2019
1 parent efe8c86 commit 793f937
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/GitLink.Tests/Providers/CustomUrlProviderFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class TheInitialization
[TestCase("https://example.com/repo", false)]
[TestCase("https://bitbucket.intra.company.com/projects/aaa/repos/a/browse/{filename}?raw", true)]
[TestCase("gopher://example.com/repo", false)]
[TestCase("http://gitlab.com/api/v4/projects/42/repository/files/{urlencoded_filename}/raw?ref={revision}&private_token=superToken", true)]
public void CorrectlyValidatesForUrls(string url, bool expectedValue)
{
var provider = new CustomUrlProvider();
Expand Down Expand Up @@ -73,14 +74,16 @@ public void ReturnsNullProjectUrl()
Assert.IsNull(provider.ProjectUrl);
}

[TestCase]
public void ReturnsValidRawGitUrl()
[TestCase(CorrectUrl)]
[TestCase("http://gitlab.com/api/v4/projects/42/repository/files/{urlencoded_filename}/raw?ref={revision}&private_token=superToken")]
public void ReturnsValidRawGitUrl(string url)
{
var provider = new CustomUrlProvider();
provider.Initialize(CorrectUrl);
provider.Initialize(url);

string correctReturnedUrl = CorrectUrl.Replace("{filename}", "%var2%");
correctReturnedUrl = correctReturnedUrl.Replace("{revision}", "{0}");
string correctReturnedUrl = url.Replace("{filename}", "%var2%")
.Replace("{revision}", "{0}")
.Replace("{urlencoded_filename}", "%var2%");

Assert.AreEqual(correctReturnedUrl, provider.RawGitUrl);
}
Expand Down

0 comments on commit 793f937

Please sign in to comment.