public void HandlesHttps() { var destination = "sourcelink.json"; var repoName = "aspnet/BuildTools"; var originUrl = $"https://github.com/{repoName}.git"; var commit = "5153bbdfa98dcc27a61d591ce09a0d632875e66f"; var rootDir = GetSourceLinkRoot(); var task = new CreateSourceLink { OriginUrl = originUrl, Commit = commit, DestinationFile = destination, SourceLinkRoot = rootDir }; try { Assert.True(task.Execute(), "The task failed but should have passed."); Assert.True(File.Exists(destination), "SourceLink file doesn't exist."); var expectedUrl = $"https://raw.githubusercontent.com/{repoName}/{commit}/*"; var expected = $"{{\"documents\":{{\"{GetExpectedRootDirectory()}*\":\"{expectedUrl}\"}}}}"; Assert.Equal(expected, File.ReadAllText(destination)); } finally { File.Delete(destination); } }
public void DoesNotChangeBackslashes(string sourceLinkRoot) { var destination = "sourcelink.json"; var repoName = "aspnet/BuildTools"; var originUrl = $"[email protected]:{repoName}.git"; var commit = "5153bbdfa98dcc27a61d591ce09a0d632875e66f"; var task = new CreateSourceLink { OriginUrl = originUrl, Commit = commit, DestinationFile = destination, SourceLinkRoot = sourceLinkRoot }; try { Assert.True(task.Execute(), "The task failed but should have passed."); Assert.True(File.Exists(destination), "SourceLink file doesn't exist."); var expectedSourceLinkRoot = sourceLinkRoot.Replace(@"\", @"\\"); var expectedUrl = $"https://raw.githubusercontent.com/{repoName}/{commit}/*"; var expected = $"{{\"documents\":{{\"{expectedSourceLinkRoot}*\":\"{expectedUrl}\"}}}}"; var resultText = File.ReadAllText(destination); Assert.Equal(expected, resultText); } finally { File.Delete(destination); } }