Skip to content

Commit

Permalink
fix: integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HamedSY committed Jul 25, 2024
1 parent 78c5e6a commit 2b17bb3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,49 @@
using Mohaymen.GiteaClient.Gitea.Client.Abstractions;
using Mohaymen.GiteaClient.Gitea.PullRequest.CreatePullRequest.Dtos;
using Mohaymen.GiteaClient.IntegrationTests.Common.Collections.Gitea;
using Mohaymen.GiteaClient.IntegrationTests.Common.Initializers.TestData.Abstractions;
using Mohaymen.GiteaClient.IntegrationTests.Common.Models;

namespace Mohaymen.GiteaClient.IntegrationTests.Gitea.PullRequest.CreatePullRequest;

[Collection("GiteaIntegrationTests")]
public class CreatePullRequestTests : IClassFixture<CreatePullRequestTestsClassFixture>
public class CreatePullRequestTests
{
private readonly IGiteaClient _sut;
private readonly ITestRepositoryCreator _repositoryCreator;
private readonly ITestBranchCreator _branchCreator;
private readonly GiteaCollectionFixture _giteaCollectionFixture;

public CreatePullRequestTests(GiteaCollectionFixture giteaCollectionFixture)
{
_giteaCollectionFixture = giteaCollectionFixture ?? throw new ArgumentNullException(nameof(giteaCollectionFixture));
_repositoryCreator = _giteaCollectionFixture.ServiceProvider.GetRequiredService<ITestRepositoryCreator>();
_branchCreator = _giteaCollectionFixture.ServiceProvider.GetRequiredService<ITestBranchCreator>();
_sut = giteaCollectionFixture.ServiceProvider.GetRequiredService<IGiteaClient>();
}

[Fact]
public async Task CreatePullRequest_ShouldGetBranchListOfRepo_WhenInputsAreProvidedProperly()
{
// Arrange
const string repositoryName = GiteaTestConstants.RepositoryName;
const string branchName = "test_branch";
var cancellationToken = _giteaCollectionFixture.CancellationToken;

await _repositoryCreator.CreateRepositoryAsync(repositoryName, cancellationToken);
await _branchCreator.CreateBranchAsync(repositoryName, branchName, cancellationToken);

const string title = "title";
var createPullRequestCommandDto = new CreatePullRequestCommandDto
{
RepositoryName = GiteaTestConstants.RepositoryName,
RepositoryName = repositoryName,
Title = title,
HeadBranch = CreatePullRequestTestsClassFixture.BranchName,
HeadBranch = branchName,
BaseBranch = GiteaTestConstants.DefaultBranch
};

// Act
var actual = await _sut.PullRequestClient.CreatePullRequestAsync(createPullRequestCommandDto, _giteaCollectionFixture.CancellationToken);
var actual = await _sut.PullRequestClient.CreatePullRequestAsync(createPullRequestCommandDto, cancellationToken);

// Assert
actual.StatusCode.Should().Be(HttpStatusCode.Created);
Expand Down

This file was deleted.

0 comments on commit 2b17bb3

Please sign in to comment.