Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useGithubStorage from GHES version checker method #1295

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
using Moq;
using OctoshiftCLI.Extensions;
using OctoshiftCLI.Services;
using OctoshiftCLI.Tests;
using Xunit;

namespace OctoshiftCLI.Tests.Octoshift.Services;

public class ArchiveUploaderTests
{
private readonly Mock<GithubClient> _githubClientMock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public async Task Sequential_Github_Ghes_Repo()
_mockGithubApi
.Setup(m => m.GetRepos(SOURCE_ORG))
.ReturnsAsync(new[] { (REPO, "private") });
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true);

var expected = $"Exec {{ gh gei migrate-repo --github-source-org \"{SOURCE_ORG}\" --source-repo \"{REPO}\" --github-target-org \"{TARGET_ORG}\" --target-repo \"{REPO}\" --ghes-api-url \"{ghesApiUrl}\" --target-repo-visibility private }}";

Expand Down Expand Up @@ -333,7 +333,7 @@ public async Task Parallel_Github_Ghes_Single_Repo()
.ReturnsAsync(new[] { (REPO, "private") });

_mockVersionProvider.Setup(m => m.GetCurrentVersion()).Returns("1.1.1");
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true);

var expected = new StringBuilder();
expected.AppendLine("#!/usr/bin/env pwsh");
Expand Down Expand Up @@ -502,7 +502,7 @@ public async Task Parallel_Github_Ghes_Single_Repo_With_Download_Migration_Logs(
.ReturnsAsync(new[] { (REPO, "private") });

_mockVersionProvider.Setup(m => m.GetCurrentVersion()).Returns("1.1.1");
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true);

var expected = new StringBuilder();
expected.AppendLine("#!/usr/bin/env pwsh");
Expand Down Expand Up @@ -588,7 +588,7 @@ public async Task Parallel_Github_Ghes_Single_Repo_No_Ssl()
.ReturnsAsync(new[] { (REPO, "private") });

_mockVersionProvider.Setup(m => m.GetCurrentVersion()).Returns("1.1.1");
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true);

var expected = new StringBuilder();
expected.AppendLine("#!/usr/bin/env pwsh");
Expand Down Expand Up @@ -673,7 +673,7 @@ public async Task Parallel_Github_Ghes_Single_Repo_Keep_Archive()
.ReturnsAsync(new[] { (REPO, "private") });

_mockVersionProvider.Setup(m => m.GetCurrentVersion()).Returns("1.1.1");
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(false);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(false);

var expected = new StringBuilder();
expected.AppendLine("#!/usr/bin/env pwsh");
Expand Down Expand Up @@ -909,7 +909,7 @@ public async Task Sequential_Ghes_Single_Repo_Aws_S3()
_mockGithubApi
.Setup(m => m.GetRepos(SOURCE_ORG))
.ReturnsAsync(new[] { (REPO, "private") });
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true);

var expected = $"Exec {{ gh gei migrate-repo --github-source-org \"{SOURCE_ORG}\" --source-repo \"{REPO}\" --github-target-org \"{TARGET_ORG}\" --target-repo \"{REPO}\" --ghes-api-url \"{ghesApiUrl}\" --aws-bucket-name \"{AWS_BUCKET_NAME}\" --aws-region \"{AWS_REGION}\" --target-repo-visibility private }}";

Expand Down Expand Up @@ -941,7 +941,7 @@ public async Task Sequential_Ghes_Single_Repo_Keep_Archive()
_mockGithubApi
.Setup(m => m.GetRepos(SOURCE_ORG))
.ReturnsAsync(new[] { (REPO, "private") });
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true);

var expected = $"Exec {{ gh gei migrate-repo --github-source-org \"{SOURCE_ORG}\" --source-repo \"{REPO}\" --github-target-org \"{TARGET_ORG}\" --target-repo \"{REPO}\" --ghes-api-url \"{ghesApiUrl}\" --aws-bucket-name \"{AWS_BUCKET_NAME}\" --aws-region \"{AWS_REGION}\" --keep-archive --target-repo-visibility private }}";

Expand Down Expand Up @@ -974,7 +974,7 @@ public async Task Validates_Env_Vars()
_mockGithubApi
.Setup(m => m.GetRepos(SOURCE_ORG))
.ReturnsAsync(new[] { (REPO, "private") });
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true);

var expected = @"
if (-not $env:GH_PAT) {
Expand Down Expand Up @@ -1019,7 +1019,7 @@ public async Task Validates_Env_Vars_AWS()
_mockGithubApi
.Setup(m => m.GetRepos(SOURCE_ORG))
.ReturnsAsync(new[] { (REPO, "private") });
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true);

var expected = @"
if (-not $env:GH_PAT) {
Expand Down Expand Up @@ -1072,7 +1072,7 @@ public async Task Validates_Env_Vars_AZURE_STORAGE_CONNECTION_STRING_Not_Validat
_mockGithubApi
.Setup(m => m.GetRepos(SOURCE_ORG))
.ReturnsAsync(new[] { (REPO, "private") });
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true);

var expected = @"
if (-not $env:AZURE_STORAGE_CONNECTION_STRING) {
Expand Down Expand Up @@ -1173,7 +1173,7 @@ public async Task Validates_Env_Vars_Blob_Storage_Not_Validated_When_GHES_3_8()
_mockGithubApi
.Setup(m => m.GetRepos(SOURCE_ORG))
.ReturnsAsync(new[] { (REPO, "private") });
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(false);
_mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(false);

var expected = @"
if (-not $env:GH_PAT) {
Expand Down
Loading
Loading