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

fixing integration tests #100

Merged
merged 19 commits into from
Dec 26, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: DotNet CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
name: DotNet Test
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Fetch tags and master for GitVersion
run: |
git fetch --tags
git branch --create-reflog master origin/master

- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '2.1.607'
- name: Setup dotnet
uses: casz/setup-dotnet@fix/dotnet-global-tool
with:
dotnet-version: '3.1.100'

# workaround for using multiple dotnet core installs
- name: .net SxS
run: rsync -a ${DOTNET_ROOT/3.1.100/2.1.607}/* $DOTNET_ROOT/

- run: dotnet tool install -g Codecov.Tool
shell: pwsh
- run: dotnet build
shell: pwsh
- run: ./test.ps1
shell: pwsh
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions GitLabApiClient.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29324.140
Expand All @@ -10,7 +10,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6E176091-1CD1-475A-AB85-C1735D9422BD}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.travis.yml = .travis.yml
appveyor.yml = appveyor.yml
build.ps1 = build.ps1
EndProjectSection
Expand Down
7 changes: 7 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
codecov:
ci:
- github.com
- appveyor

comment:
layout: "header, diff, tree, changes"
16 changes: 0 additions & 16 deletions docker/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions docker/authentication_token.sh

This file was deleted.

18 changes: 0 additions & 18 deletions docker/docker-compose.yml

This file was deleted.

5 changes: 0 additions & 5 deletions docker/entrypoint.sh

This file was deleted.

7 changes: 7 additions & 0 deletions docker/gitlab.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby

prometheus['enable'] = false
prometheus_monitoring['enable'] = false
alertmanager['enable'] = false
grafana['enable'] = false
gitlab_rails['initial_root_password'] = 'password'
14 changes: 14 additions & 0 deletions docker/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
u = User.first

g = Group.create!(name: 'txxxestgrouxxxp', path: 'txxxestgrouxxxp')
g.add_developer(u)
p = Project.create!(namespace: g, creator: u, path: 'txxxestprojecxxxt', name: 'txxxestprojecxxxt')
p.repository.create_if_not_exists
p.add_maintainer(u)
c = p.repository.create_dir(u, 'newdir', message: 'Create newdir', branch_name: 'master')

t = PersonalAccessToken.new({ user: u, name: 'gitlab-api-client', scopes: ['api']})
t.save!

puts t.token
25 changes: 0 additions & 25 deletions docker/test_setup.sh

This file was deleted.

1 change: 0 additions & 1 deletion docker/volumes/placeholder.gitkeep

This file was deleted.

8 changes: 4 additions & 4 deletions src/GitLabApiClient/GitLabApiClient.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition="'$(OS)' != 'Unix'">netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Unix'">netstandard2.0;net48;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netstandard2.0;netcoreapp3.1</TargetFrameworks>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Copyright />
<Description>GitLabApiClient is a .NET rest client for GitLab API v4.</Description>
Expand All @@ -19,11 +19,11 @@

<ItemGroup>
<PackageReference Include="GitVersionTask" Version="5.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<Reference Include="System.Net.Http" />
<Reference Include="System.Web" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/GitLabApiClient/IssuesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public async Task<IList<Note>> GetNotesAsync(ProjectId projectId, int issueIid,
/// <param name="issueIid">The IID of an issue.</param>
/// <param name="noteId">The ID of a note.</param>
/// <param name="request">Update issue note request.</param>
public async Task<Issue> UpdateNoteAsync(ProjectId projectId, int issueIid, int noteId, UpdateIssueNoteRequest request) =>
await _httpFacade.Put<Issue>($"projects/{projectId}/issues/{issueIid}/notes/{noteId}", request);
public async Task<Note> UpdateNoteAsync(ProjectId projectId, int issueIid, int noteId, UpdateIssueNoteRequest request) =>
await _httpFacade.Put<Note>($"projects/{projectId}/issues/{issueIid}/notes/{noteId}", request);

/// <summary>
/// Deletes an existing note (comment) of an issue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ namespace GitLabApiClient.Models.Releases.Requests
/// </summary>
public sealed class UpdateReleaseRequest
{
[JsonProperty("tag_name")]
public string TagName { get; set; }
[JsonProperty("name")]
public string ReleaseName { get; set; }
[JsonProperty("description")]
Expand All @@ -26,10 +24,9 @@ public sealed class UpdateReleaseRequest
/// <param name="tagName">The name of the tag, the release will be created from</param>
/// <param name="description">The description for the release.</param>
/// <param name="releasedAt">The date the release will be/was ready.</param>
public UpdateReleaseRequest(string releaseName, string tagName, string description, DateTime? releasedAt = null)
public UpdateReleaseRequest(string releaseName, string description, DateTime? releasedAt = null)
{
ReleaseName = releaseName;
TagName = tagName;
Description = description;
ReleasedAt = releasedAt;
}
Expand Down
8 changes: 5 additions & 3 deletions src/GitLabApiClient/ReleaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using GitLabApiClient.Internal.Http;
using GitLabApiClient.Internal.Paths;
using GitLabApiClient.Internal.Queries;
using GitLabApiClient.Internal.Utilities;
using GitLabApiClient.Models.Projects.Responses;
using GitLabApiClient.Models.Releases.Requests;
using GitLabApiClient.Models.Releases.Responses;
Expand Down Expand Up @@ -60,10 +61,11 @@ public async Task<IList<Release>> GetAsync(ProjectId projectId, Action<ReleaseQu
/// Update a release
/// </summary>
/// <param name="projectId">The ID, path or <see cref="Project"/> of the project.</param>
/// <param name="tagName">The tag name of the release, you want to update.</param>
/// <param name="request">Update release request</param>
/// <returns></returns>
public async Task<Release> UpdateAsync(ProjectId projectId, UpdateReleaseRequest request) =>
await _httpFacade.Put<Release>($"projects/{projectId}/releases", request);
public async Task<Release> UpdateAsync(ProjectId projectId, string tagName, UpdateReleaseRequest request) =>
await _httpFacade.Put<Release>($"projects/{projectId}/releases/{tagName.UrlEncode()}", request);

/// <summary>
/// Delete a release
Expand All @@ -72,6 +74,6 @@ public async Task<IList<Release>> GetAsync(ProjectId projectId, Action<ReleaseQu
/// <param name="tagName">The tag name of the release, you want to delete.</param>
/// <returns></returns>
public async Task DeleteAsync(ProjectId projectId, string tagName) =>
await _httpFacade.Delete($"projects/{projectId}/releases/{tagName}");
await _httpFacade.Delete($"projects/{projectId}/releases/{tagName.UrlEncode()}");
}
}
22 changes: 15 additions & 7 deletions test.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
& dotnet test --filter Category!=LinuxIntegration --settings coverletArgs.runsettings --no-build --no-restore
$dockerOSType = docker info --format "{{.OSType}}"
if ($dockerOSType -ieq 'linux') {
& dotnet test --verbosity normal --settings coverletArgs.runsettings --no-build --no-restore
} else {
& dotnet test --filter Category!=LinuxIntegration --verbosity normal --settings coverletArgs.runsettings --no-build --no-restore
}

$exitWithError = $LastExitCode -ne 0

if ($LastExitCode -ne 0)
{
exit 1
$openCoverFile = Get-ChildItem -Path "test/*/coverage.opencover.xml" -Recurse | Sort-Object LastWriteTime | Select-Object -last 1
if (Test-Path "$openCoverFile") {
Write-Host "Uploading coverage file"
& codecov -f "$openCoverFile" -t bda1c835-c4a2-4a1a-8d38-999b9a8ea80b
}

Write-Host "Uploading coverage file"
$openCoverFile = (Get-ChildItem -Path "test/*/coverage.opencover.xml" -Recurse | Sort-Object LastWriteTime | Select-Object -last 1).FullName
& codecov -f "$openCoverFile" -t bda1c835-c4a2-4a1a-8d38-999b9a8ea80b
if ($exitWithError) {
exit 1
}
7 changes: 4 additions & 3 deletions test/GitLabApiClient.Test/GitLabApiClient.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand All @@ -11,7 +11,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="1.1.0" />
<PackageReference Include="FakeItEasy" Version="5.4.0" />
<PackageReference Include="Ductus.FluentDocker" Version="2.7.46-beta0080" />
<PackageReference Include="FakeItEasy" Version="5.5.0" />
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
18 changes: 9 additions & 9 deletions test/GitLabApiClient.Test/GroupsClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace GitLabApiClient.Test
public class GroupsClientTest
{
private readonly List<int> _groupIdsToClean = new List<int>();
private List<int> _milestoneIdsToClean { get; } = new List<int>();
private List<int> MilestoneIdsToClean { get; } = new List<int>();

private readonly GroupsClient _sut = new GroupsClient(
GetFacade(),
Expand All @@ -32,7 +32,7 @@ public async Task GroupCanBeRetrievedByGroupId()
group.FullPath.Should().Be(TestGroupName);
group.Name.Should().Be(TestGroupName);
group.Path.Should().Be(TestGroupName);
group.Visibility.Should().Be(GroupsVisibility.Private);
group.Visibility.Should().Be(GroupsVisibility.Public);
group.Description.Should().BeEmpty();
}

Expand All @@ -55,7 +55,7 @@ public async Task GroupsCanBeRetrievedFromQuery()
{
var group = await _sut.GetAsync(o =>
{
o.Search = "gitlab";
o.Search = "txxxest";
o.Order = GroupsOrder.Name;
o.Sort = GroupsSort.Descending;
o.AllAvailable = true;
Expand All @@ -75,7 +75,7 @@ public async Task GroupMilestonesCanBeRetrieved()
DueDate = "2018-11-30",
Description = "description1"
});
_milestoneIdsToClean.Add(createdMilestone.Id);
MilestoneIdsToClean.Add(createdMilestone.Id);

//act
var milestones = await _sut.GetMilestonesAsync(TestGroupId);
Expand All @@ -86,8 +86,8 @@ public async Task GroupMilestonesCanBeRetrieved()
milestone.Should().Match<Milestone>(m =>
m.GroupId == TestGroupId &&
m.Title == "milestone1" &&
m.StartDate == "2018-11-05" &&
m.DueDate == "2018-11-10" &&
m.StartDate == "2018-11-01" &&
m.DueDate == "2018-11-30" &&
m.Description == "description1");
}

Expand Down Expand Up @@ -159,7 +159,7 @@ public async Task CreatedGroupMilestoneCanBeUpdated()
DueDate = "2018-11-30",
Description = "description2"
});
_milestoneIdsToClean.Add(createdMilestone.Id);
MilestoneIdsToClean.Add(createdMilestone.Id);

//act
var updatedMilestone = await _sut.UpdateMilestoneAsync(TestGroupTextId, createdMilestone.Id, new UpdateGroupMilestoneRequest()
Expand Down Expand Up @@ -189,7 +189,7 @@ public async Task CreatedGroupMilestoneCanBeClosed()
DueDate = "2018-12-31",
Description = "description3"
});
_milestoneIdsToClean.Add(createdMilestone.Id);
MilestoneIdsToClean.Add(createdMilestone.Id);

//act
var updatedMilestone = await _sut.UpdateMilestoneAsync(TestGroupTextId, createdMilestone.Id, new UpdateGroupMilestoneRequest()
Expand All @@ -211,7 +211,7 @@ public Task DisposeAsync()

private async Task CleanupGroups()
{
foreach (int milestoneId in _milestoneIdsToClean)
foreach (int milestoneId in MilestoneIdsToClean)
await _sut.DeleteMilestoneAsync(TestGroupId, milestoneId);

foreach (int groupId in _groupIdsToClean)
Expand Down
Loading