public GitHutReleaseRetrieverFixture(string assetName, string oauthToken)
 {
     AssetName    = assetName;
     HttpMock     = HttpMockRepository.At(BasePath);
     PathPartMock = new GitHubUrlPathParts
     {
         Base = BasePath
     };
     UrlHelper   = new GitHubApiUrlHelper(PathPartMock);
     LogDummy    = new RetrieverLogFixture();
     GetInstance = new GitHubReleaseRetriever(UrlHelper, LogDummy, oauthToken);
 }
        public void LatestReleaseUrlIsConstructedCorrectly()
        {
            // arrange
            const string owner       = "NinetailLabs";
            const string repo        = "VaraniumSharp";
            var          expectedUrl = $"https://api.github.com/repos/{owner}/{repo}/releases/latest";
            var          parts       = new GitHubUrlPathParts();
            var          sut         = new GitHubApiUrlHelper(parts);

            // act
            var retrievalUrl = sut.LatestReleaseUrl(owner, repo);

            // asset
            retrievalUrl.Should().Be(expectedUrl);
        }
Esempio n. 3
0
        public static void RetrievePaketBootstrapper(this ICakeContext context, DirectoryPath paketDirectory, string githubOAuthToken)
        {
            var urlPartHelper = new GitHubUrlPathParts
            {
                Base = GithubUrlPath
            };

            var urlHelper        = new GitHubApiUrlHelper(urlPartHelper);
            var retrieverLog     = new CakeRetrieverLog(context.Log);
            var releaseRetriever = new GitHubReleaseRetriever(urlHelper, retrieverLog, githubOAuthToken);

            paketDirectory.CheckAndCreateDirectory(context.Log);
            if (File.Exists(Path.Combine(paketDirectory.FullPath, PaketAsset)))
            {
                context.Log.Information("Paket Bootstrapper already exists - skipping download");
                return;
            }

            var latestUrl = releaseRetriever.GetLatestReleaseUrlAsync(PaketOwner, PaketRepo, PaketAsset).Result;

            if (string.IsNullOrEmpty(latestUrl))
            {
                context.Log.Error("Failed to retrieve link for latest Paket BootStrapper");
                throw new CakeException("Failed to retrieve link for latest Paket Bootstrapper");
            }

            var result = releaseRetriever.DownloadFileAsync(latestUrl, paketDirectory.FullPath, PaketAsset).Result;

            if (!result)
            {
                context.Log.Error("An error occured while trying to retrieve the Paket Bootstrapper");
                throw new CakeException("Error occured while trying to retrieve the Paket Bootstrapper");
            }

            context.Log.Information("Completed retrieval of the Paket Bootstrapper");
        }