Skip to content

Address change requests for Generic Package upload from ubisoft/NGitLab#524 #1

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

Open
wants to merge 123 commits into
base: upload-generic-packages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
64ffd1d
Bump Meziantou.Analyzer from 2.0.84 to 2.0.85 (#526)
dependabot[bot] Sep 18, 2023
ab145ab
Bump NSubstitute from 5.0.0 to 5.1.0 (#522)
dependabot[bot] Sep 18, 2023
8817e11
Support pipeline retry endpoint (#527)
meziantou Sep 18, 2023
eb4f261
Bump Microsoft.Playwright from 1.37.1 to 1.38.0 (#529)
dependabot[bot] Sep 25, 2023
1598f2e
Bump YamlDotNet from 13.3.1 to 13.4.0 (#530)
dependabot[bot] Sep 25, 2023
adea364
Bump Microsoft.NET.Test.Sdk from 17.7.1 to 17.7.2 (#519)
dependabot[bot] Sep 25, 2023
1f81a27
Support sub modules in mocks (#528)
jairbubbles Sep 28, 2023
ac714a5
Bump Polly from 7.2.4 to 8.0.0 (#533)
dependabot[bot] Oct 2, 2023
c8b1b52
Bump Meziantou.Analyzer from 2.0.85 to 2.0.91 (#532)
dependabot[bot] Oct 3, 2023
705e880
Migrate NGitLab from net461 to net462 + bump up LangVersion to 11.0 (…
louis-z Oct 4, 2023
ccc6a66
Bump YamlDotNet from 13.4.0 to 13.5.2 (#536)
dependabot[bot] Oct 10, 2023
20e57d3
Bump Meziantou.Analyzer from 2.0.91 to 2.0.92 (#535)
dependabot[bot] Oct 10, 2023
6309532
Support setting multiple assignees for issues (#541)
PMExtra Oct 13, 2023
1834ec9
Bump Meziantou.Analyzer from 2.0.92 to 2.0.93 (#545)
dependabot[bot] Oct 16, 2023
ad6594f
Bump YamlDotNet from 13.5.2 to 13.7.1 (#544)
dependabot[bot] Oct 16, 2023
8ba3bc6
Add missing attribute `user_notes_count` to merge requests (#542)
PMExtra Oct 16, 2023
09cdaae
Remove the default `target_project_id` when creating merge request (#…
PMExtra Oct 17, 2023
6368d6a
Support downloading a single artifact file (#539)
PMExtra Oct 17, 2023
8b8d882
Bump Microsoft.Playwright from 1.38.0 to 1.39.0 (#548)
dependabot[bot] Oct 23, 2023
5346942
Bump Meziantou.Analyzer from 2.0.93 to 2.0.94 (#549)
dependabot[bot] Oct 23, 2023
dee78df
Add ResourceEvents for merge requests (#547)
phdesroUbi Oct 24, 2023
1ba8140
Add TimeStatsAsync to MergeRequestClient (#543)
DelphinRP Oct 25, 2023
749c590
Bump Meziantou.Analyzer from 2.0.94 to 2.0.103 (#551)
dependabot[bot] Oct 30, 2023
44157b8
Support for using URL-encoded paths as group or project ids (#550)
PMExtra Nov 3, 2023
99b0710
Bump Polly from 8.0.0 to 8.1.0 (#556)
dependabot[bot] Nov 6, 2023
3c1289b
Draft status missing in MergeRequest class (#553)
phdesroUbi Nov 6, 2023
7293f61
Bump Meziantou.Analyzer from 2.0.103 to 2.0.109 (#558)
dependabot[bot] Nov 13, 2023
aac3dca
Bump NUnit from 3.13.3 to 3.14.0 (#554)
dependabot[bot] Nov 13, 2023
1900a94
Replace recent [Obsolete] additions with [EditorBrowsable] (#559)
louis-z Nov 13, 2023
f8b5eef
Bump Microsoft.NET.Test.Sdk from 17.7.2 to 17.8.0 (#557)
dependabot[bot] Nov 13, 2023
a48aa40
NGitLab.Mock.Repository.GetCommits() should support a revision range …
louis-z Nov 13, 2023
d7c4ec1
Bump LibGit2Sharp from 0.27.2 to 0.28.0 (#555)
dependabot[bot] Nov 16, 2023
97a0852
Add runner registration/delete mock (#562)
BallyB Nov 16, 2023
613bee0
Add ability to do a code compare. (#444)
shivan Nov 17, 2023
e1e9356
Add runner token to clientproject (#565)
BallyB Nov 17, 2023
3157774
Bump Microsoft.CodeAnalysis.NetAnalyzers from 7.0.4 to 8.0.0 (#572)
dependabot[bot] Nov 20, 2023
3418e61
Bump Microsoft.Extensions.Http from 7.0.0 to 8.0.0 (#569)
dependabot[bot] Nov 20, 2023
e145b88
Bump NuGet.Versioning from 6.7.0 to 6.8.0 (#566)
dependabot[bot] Nov 20, 2023
8e8f9f2
Bump Microsoft.Bcl.AsyncInterfaces from 7.0.0 to 8.0.0 (#567)
dependabot[bot] Nov 20, 2023
95ea5e1
Bump System.Text.Json from 7.0.3 to 8.0.0 (#573)
dependabot[bot] Nov 20, 2023
83707f3
Bump Meziantou.Analyzer from 2.0.109 to 2.0.110 (#571)
dependabot[bot] Nov 20, 2023
13c15a7
Bump Meziantou.Framework.Versioning from 1.3.2 to 1.3.3 (#568)
dependabot[bot] Nov 20, 2023
918f10a
Bump Polly from 8.1.0 to 8.2.0 (#574)
dependabot[bot] Nov 20, 2023
e02fe36
Add ability to get job artifact by Ref (#564)
shivan Nov 21, 2023
203ffb8
Add missing attribute `target` and `protected` to tag (#576)
Sjhzjxc Nov 21, 2023
900721f
Put Microsoft NuGet packages into their own dependabot group (#575)
louis-z Nov 23, 2023
4df7807
Exclude "Microsoft.Playwright" from 'ms-dependencies' group (#579)
louis-z Nov 23, 2023
55348e5
Bump up to .NET 8 (#581)
louis-z Nov 23, 2023
b740463
Bump the ms-dependencies group with 1 update (#580)
dependabot[bot] Nov 23, 2023
81e264c
Add protected tags client (#577)
Sjhzjxc Nov 24, 2023
5e99e33
Bump Microsoft.Playwright from 1.39.0 to 1.40.0 (#585)
dependabot[bot] Nov 27, 2023
f154d39
Bump Meziantou.Analyzer from 2.0.110 to 2.0.112 (#583)
dependabot[bot] Nov 27, 2023
bbc6deb
Bump NUnit from 3.14.0 to 4.0.0 (#584)
dependabot[bot] Nov 27, 2023
c72c21d
Extend Mock to further support so-called LintCI (#582)
louis-z Nov 27, 2023
03593a7
Make comparison of string SHA1s in mock case-insensitive (#586)
louis-z Nov 28, 2023
77089be
Bump Meziantou.Analyzer from 2.0.112 to 2.0.118 (#588)
dependabot[bot] Dec 4, 2023
357e208
Bump LibGit2Sharp from 0.28.0 to 0.29.0 (#589)
dependabot[bot] Dec 4, 2023
ee644fe
Return empty list of environment in Mock EnvironmentClient (#590)
LaurentM-Ubi Dec 5, 2023
1406016
Add support for project's "releases_access_level" + a bit more (#591)
louis-z Dec 6, 2023
8704e7f
Bump actions/setup-dotnet from 3 to 4 (#592)
dependabot[bot] Dec 11, 2023
9d77aa8
Bump NUnit from 4.0.0 to 4.0.1 (#593)
dependabot[bot] Dec 11, 2023
8ab7396
Bump Meziantou.Analyzer from 2.0.118 to 2.0.123 (#598)
dependabot[bot] Dec 18, 2023
0b94429
Bump Meziantou.Framework.Versioning from 1.3.3 to 1.3.4 (#595)
dependabot[bot] Dec 18, 2023
c292927
Fix adding the wrong scope parameter. (#599)
Sjhzjxc Dec 18, 2023
cc093df
Configure GitHub Actions' updates to be grouped into a single PR (#600)
louis-z Dec 18, 2023
658a3fb
Bump the github-actions group with 2 updates (#601)
dependabot[bot] Dec 18, 2023
4278a31
Add Merge Error field on Merge Request Model (#602)
mlemieuxlafontaine-ubi Dec 18, 2023
f8031d8
Improve NUnit tests (#603)
louis-z Dec 20, 2023
329c3db
Use file-scoped namespaces (#604)
louis-z Dec 21, 2023
a9662bd
Bump Meziantou.Analyzer from 2.0.123 to 2.0.132 (#607)
dependabot[bot] Jan 4, 2024
3d9e43d
Bump StyleCop.Analyzers from 1.2.0-beta.507 to 1.2.0-beta.556 (#606)
dependabot[bot] Jan 4, 2024
43c486a
Group code analyzers' updates into a single PR (#608)
louis-z Jan 4, 2024
f361d37
Bump the code-analyzers group with 1 update (#611)
dependabot[bot] Jan 8, 2024
f2543e9
Bump Polly from 8.2.0 to 8.2.1 (#610)
dependabot[bot] Jan 8, 2024
8ac46a1
Implement resetApprovals endpoint (#614)
deimosowen Jan 15, 2024
15d4deb
Set global.json's "rollForward" to "major" rather than "latestMajor" …
louis-z Jan 19, 2024
8360110
Bump Microsoft.Playwright from 1.40.0 to 1.41.1 (#618)
dependabot[bot] Jan 22, 2024
f24e5b4
Add position property when getting merge request comments (#621)
Codex04 Jan 26, 2024
51d2f9f
Get Group MergeRequests (#620)
Yekonori Jan 26, 2024
1315529
Bump Microsoft.Playwright from 1.41.1 to 1.41.2 (#623)
dependabot[bot] Jan 29, 2024
34fb23e
Bump the code-analyzers group with 2 updates (#624)
dependabot[bot] Jan 29, 2024
00c3542
Allow MR Comment Range type to be nullable (#625)
mlemieuxlafontaine-ubi Feb 1, 2024
7c8fcfd
Bump the code-analyzers group with 1 update (#627)
dependabot[bot] Feb 5, 2024
a1c5a55
Bump the code-analyzers group with 1 update (#629)
dependabot[bot] Feb 12, 2024
25d3363
Bump Polly from 8.2.1 to 8.3.0 (#630)
dependabot[bot] Feb 12, 2024
e119678
Bump the ms-dependencies group with 3 updates (#631)
dependabot[bot] Feb 14, 2024
4e6dc39
Revert "Bump the ms-dependencies group with 3 updates (#631)" (#632)
louis-z Feb 16, 2024
10c934c
Bump NuGet.Versioning from 6.8.0 to 6.9.1 (#635)
dependabot[bot] Feb 19, 2024
be695d6
Bump the code-analyzers group with 1 update (#634)
dependabot[bot] Feb 19, 2024
4ce154f
Bump coverlet.collector from 6.0.0 to 6.0.1 (#639)
dependabot[bot] Feb 26, 2024
b0e0ec1
Bump the code-analyzers group with 1 update (#637)
dependabot[bot] Feb 26, 2024
337b66a
Bump NUnit from 4.0.1 to 4.1.0 (#638)
dependabot[bot] Feb 26, 2024
7f23c99
Bump MinVer from 4.3.0 to 5.0.0 (#644)
dependabot[bot] Mar 4, 2024
5e3be20
Bump the ms-dependencies group with 3 updates (#643)
dependabot[bot] Mar 4, 2024
746af04
Bump Polly from 8.3.0 to 8.3.1 (#645)
dependabot[bot] Mar 11, 2024
204a795
Bump Microsoft.Playwright from 1.41.2 to 1.42.0 (#646)
dependabot[bot] Mar 11, 2024
2ae5ce0
Make it possible to create discusion for a specific change (#647)
Codex04 Mar 11, 2024
1c4f546
Update `IGroupsClient` to support paging of groups and projects (#642)
belcher-rok Mar 11, 2024
86c9d4e
Add CreateAsync to UserClient (#641)
kevingentile Mar 12, 2024
25b329f
Bump the code-analyzers group with 2 updates (#649)
dependabot[bot] Mar 18, 2024
cbfa21e
Bump the ms-dependencies group with 2 updates (#648)
dependabot[bot] Mar 18, 2024
1378a00
Bump coverlet.collector from 6.0.1 to 6.0.2 (#650)
dependabot[bot] Mar 20, 2024
e46467d
Add async functions to `IMembersClient` and other changes (#652)
belcher-rok Mar 27, 2024
4fbf39a
Bump LibGit2Sharp from 0.29.0 to 0.30.0 (#653)
dependabot[bot] Apr 2, 2024
87fed0b
Make Position.BaseSha nullable (#657)
louis-z Apr 4, 2024
1e153b9
Add async CRUD methods to `IProjectClient` (#655)
belcher-rok Apr 10, 2024
0403aa7
Make Utils.AddParameter<T>() consider EnumMemberAttribute (#660)
louis-z Apr 12, 2024
b911b96
Add support to Group hooks (#661)
PrashanthiRamesh Apr 24, 2024
6f5dc8a
Project Update mock should set the BuildTimeout in seconds (#664)
PrashanthiRamesh May 1, 2024
c8418b2
Add IUserClient.CreateTokenAsync() and Group.CreatedAt prop (#665)
belcher-rok May 1, 2024
9e7e8f3
added missing page parameter in event query (#667)
TheVVaS May 2, 2024
fa9a441
Rename IPackageClient.PublishAsync() to IPackageClient.PublishGeneric…
ap0llo May 5, 2024
ca0aa43
Use C#-style names for package enums
ap0llo May 5, 2024
b81d6b7
Avoid usage of file system in PackageTests
ap0llo May 5, 2024
4da9b15
Adjust naming of properties in Package class
ap0llo May 5, 2024
34acd27
Use long instead of int for ids and file sizes
ap0llo May 5, 2024
e923baa
Model PackagePublish.Status as enum and make it optional
ap0llo May 5, 2024
ff22696
Rename property PackagePublish.PackageStream to FileStream to emphasi…
ap0llo May 5, 2024
5cf4f29
Use GitLabCollectionResponse<T> instead of IEnumerable<T> in Package …
ap0llo May 5, 2024
27b4b2b
Merge remote-tracking branch 'upstream-upstream/main' into upload-gen…
ap0llo May 5, 2024
97fd9c8
Use ProjectId instead of int in package client
ap0llo May 5, 2024
4fdee54
Add option to query packages by version
ap0llo May 5, 2024
d62c353
Remove unused propety "PackageId" from PackageQuery class
ap0llo May 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_methods = false:silent
Expand Down Expand Up @@ -260,6 +260,9 @@ dotnet_diagnostic.SA1101.severity = none
# SA1116: Split parameters should start on line after declaration
dotnet_diagnostic.SA1116.severity = silent

# SA1118: Parameter should not span multiple lines
dotnet_diagnostic.SA1118.severity = suggestion

# SA1122: Use string.Empty for empty strings
dotnet_diagnostic.SA1122.severity = none

Expand Down
16 changes: 15 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
Expand All @@ -18,6 +18,10 @@ updates:
interval: weekly
rebase-strategy: auto
open-pull-requests-limit: 20
groups:
github-actions:
patterns:
- "*"

- package-ecosystem: "npm"
directory: "/"
Expand All @@ -32,3 +36,13 @@ updates:
interval: weekly
rebase-strategy: auto
open-pull-requests-limit: 20
groups:
code-analyzers:
patterns:
- "*Analyzer*"
ms-dependencies:
patterns:
- "Microsoft.*"
- "System.*"
exclude-patterns:
- "Microsoft.Playwright"
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ jobs:
with:
fetch-depth: 0 # Get all the history so MinGit can compute the version
- name: Setup .NET Core (latest)
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
- run: dotnet pack NGitLab.sln --configuration Release --output ${{ env.NuGetDirectory }} /bl
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/**/*
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: binlogs
if-no-files-found: error
Expand All @@ -51,8 +51,8 @@ jobs:
# Keep in sync with the version in GitLabDockerContainer.cs
# Available tags: https://hub.docker.com/r/gitlab/gitlab-ee/tags
gitlab: [
'gitlab/gitlab-ee:15.4.6-ee.0',
'gitlab/gitlab-ee:15.11.9-ee.0',
'gitlab/gitlab-ee:15.11.13-ee.0',
]
configuration: [ Release ]
fail-fast: false
Expand All @@ -67,15 +67,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (latest)
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
- run: |
$value = "${{ matrix.gitlab }}-${{ matrix.configuration }}".Replace(':', '-').Replace('/', '-')
"artifact_name=test-results-$value" >> $env:GITHUB_OUTPUT
name: Set artifact name
id: set-artifact-name
- run: dotnet test --configuration ${{ matrix.configuration }} --logger trx --results-directory "${{ env.TestResultsDirectory }}" --collect:"XPlat Code Coverage" /p:RunAnalyzers=false
name: Run tests
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ steps.set-artifact-name.outputs.artifact_name }}
Expand All @@ -96,12 +96,12 @@ jobs:
runs-on: 'ubuntu-20.04'
needs: [ create_nuget, build_and_test ]
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
- run: |
Write-Host "Current ref: $env:GITHUB_REF"
Write-Host "Searching nupkg in folder: ${{ env.NuGetDirectory }}"
Expand Down
2 changes: 1 addition & 1 deletion BannedSymbols.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#https://github.com/dotnet/csharplang/blob/main/spec/documentation-comments.md#id-string-format
// https://github.com/dotnet/csharpstandard/blob/standard-v6/standard/documentation-comments.md#d42-id-string-format

M:System.String.ToLower;Use ToLowerInvariant instead
M:System.String.ToUpper;Use ToUpperInvariant instead
Expand Down
12 changes: 6 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<!-- Assembly Info -->
<Company>Ubisoft</Company>
Expand All @@ -8,7 +8,7 @@
<Authors>$(Company), NGitLab contributors</Authors>

<!-- Compile Options -->
<LangVersion>10.0</LangVersion>
<LangVersion>11.0</LangVersion>
<Deterministic>true</Deterministic>
<Features>strict</Features>
<TreatWarningsAsErrors Condition="'$(Configuration)' != 'Debug'">true</TreatWarningsAsErrors>
Expand All @@ -27,7 +27,7 @@
<SourceRoot Include="$(MSBuildThisFileDirectory)/" />

<AdditionalFiles Include="$(MSBuildThisFileDirectory)/BannedSymbols.txt" Link="Properties/BannedSymbols.txt" />
<PackageReference Include="MinVer" PrivateAssets="All" Version="4.3.0" />
<PackageReference Include="MinVer" PrivateAssets="All" Version="5.0.0" />

<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -37,17 +37,17 @@

<!-- Analyzers (Roslyn, Meziantou, StyleCop, ...) -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<PackageReference Include="Meziantou.Analyzer" Version="2.0.84">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
57 changes: 28 additions & 29 deletions NGitLab.Mock.Tests/BotUserTests.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
using NGitLab.Models;
using NUnit.Framework;

namespace NGitLab.Mock.Tests
namespace NGitLab.Mock.Tests;

public sealed class BotUserTests
{
public sealed class BotUserTests
[Test]
public void Test_project_bot_user()
{
[Test]
public void Test_project_bot_user()
{
using var server = new GitLabServer();
var group = new Group("test");
var project = new Project("test-project");
server.Groups.Add(group);
group.Projects.Add(project);
using var server = new GitLabServer();
var group = new Group("test");
var project = new Project("test-project");
server.Groups.Add(group);
group.Projects.Add(project);

var bot = project.CreateBotUser("token_name", AccessLevel.Maintainer);
var bot = project.CreateBotUser("token_name", AccessLevel.Maintainer);

Assert.That(bot.Bot, Is.True);
Assert.That(bot.Name, Is.EqualTo("token_name"));
var permissions = project.GetEffectivePermissions();
var botPermission = permissions.GetEffectivePermission(bot);
Assert.That(botPermission.AccessLevel, Is.EqualTo(AccessLevel.Maintainer));
}
Assert.That(bot.Bot, Is.True);
Assert.That(bot.Name, Is.EqualTo("token_name"));
var permissions = project.GetEffectivePermissions();
var botPermission = permissions.GetEffectivePermission(bot);
Assert.That(botPermission.AccessLevel, Is.EqualTo(AccessLevel.Maintainer));
}

[Test]
public void Test_group_bot_user()
{
using var server = new GitLabServer();
var group = new Group("test");
server.Groups.Add(group);
[Test]
public void Test_group_bot_user()
{
using var server = new GitLabServer();
var group = new Group("test");
server.Groups.Add(group);

var bot = group.CreateBotUser(AccessLevel.Maintainer);
var bot = group.CreateBotUser(AccessLevel.Maintainer);

Assert.That(bot.Bot, Is.True);
var permissions = group.GetEffectivePermissions();
var botPermission = permissions.GetEffectivePermission(bot);
Assert.That(botPermission.AccessLevel, Is.EqualTo(AccessLevel.Maintainer));
}
Assert.That(bot.Bot, Is.True);
var permissions = group.GetEffectivePermissions();
var botPermission = permissions.GetEffectivePermission(bot);
Assert.That(botPermission.AccessLevel, Is.EqualTo(AccessLevel.Maintainer));
}
}
67 changes: 33 additions & 34 deletions NGitLab.Mock.Tests/BranchesMockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,40 @@
using NGitLab.Mock.Config;
using NUnit.Framework;

namespace NGitLab.Mock.Tests
namespace NGitLab.Mock.Tests;

public class BranchesMockTests
{
public class BranchesMockTests
[Test]
public void Test_search_branches()
{
[Test]
public void Test_search_branches()
{
using var server = new GitLabConfig()
.WithUser("user1", isDefault: true)
.WithProject("test-project", id: 1, addDefaultUserAsMaintainer: true, defaultBranch: "main", configure: project => project
.WithCommit("Initial commit")
.WithCommit("Commit for branch_1", sourceBranch: "branch_1"))
.BuildServer();

var client = server.CreateClient("user1");
var branchClient = client.GetRepository(1).Branches;

var branches = branchClient.Search("main").ToList();
var expectedBranch = branches.Single();
Assert.AreEqual("main", expectedBranch.Name);

branches = branchClient.Search("^main$").ToList();
expectedBranch = branches.Single();
Assert.AreEqual("main", expectedBranch.Name);

branches = branchClient.Search("^branch").ToList();
expectedBranch = branches.Single();
Assert.AreEqual("branch_1", expectedBranch.Name);

branches = branchClient.Search("1$").ToList();
expectedBranch = branches.Single();
Assert.AreEqual("branch_1", expectedBranch.Name);

branches = branchClient.Search("foobar").ToList();
Assert.IsEmpty(branches);
}
using var server = new GitLabConfig()
.WithUser("user1", isDefault: true)
.WithProject("test-project", id: 1, addDefaultUserAsMaintainer: true, defaultBranch: "main", configure: project => project
.WithCommit("Initial commit")
.WithCommit("Commit for branch_1", sourceBranch: "branch_1"))
.BuildServer();

var client = server.CreateClient("user1");
var branchClient = client.GetRepository(1).Branches;

var branches = branchClient.Search("main").ToList();
var expectedBranch = branches.Single();
Assert.That(expectedBranch.Name, Is.EqualTo("main"));

branches = branchClient.Search("^main$").ToList();
expectedBranch = branches.Single();
Assert.That(expectedBranch.Name, Is.EqualTo("main"));

branches = branchClient.Search("^branch").ToList();
expectedBranch = branches.Single();
Assert.That(expectedBranch.Name, Is.EqualTo("branch_1"));

branches = branchClient.Search("1$").ToList();
expectedBranch = branches.Single();
Assert.That(expectedBranch.Name, Is.EqualTo("branch_1"));

branches = branchClient.Search("foobar").ToList();
Assert.That(branches, Is.Empty);
}
}
Loading