Skip to content

Commit 8bf473e

Browse files
authored
Replace int IDs by long ones + a few more changes (#811)
* Replace int IDs by long ones Remove redundant stuff * Remove obsolete code * Tweak * Address issue 797 * review + a few more changes related to runners
1 parent 77e89b5 commit 8bf473e

File tree

254 files changed

+1427
-2039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

254 files changed

+1427
-2039
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Authors>$(Company), NGitLab contributors</Authors>
99

1010
<!-- Compile Options -->
11-
<LangVersion>11.0</LangVersion>
11+
<LangVersion>12</LangVersion>
1212
<Deterministic>true</Deterministic>
1313
<Features>strict</Features>
1414
<TreatWarningsAsErrors Condition="'$(Configuration)' != 'Debug'">true</TreatWarningsAsErrors>

NGitLab.Mock.Tests/MergeRequestsMockTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void Test_merge_requests_approvable_by_me_can_be_listed()
5757
.BuildServer();
5858

5959
var client = server.CreateClient("user1");
60-
var mergeRequests = client.MergeRequests.Get(new MergeRequestQuery { ApproverIds = new[] { 1 } }).ToArray();
60+
var mergeRequests = client.MergeRequests.Get(new MergeRequestQuery { ApproverIds = [1L] }).ToArray();
6161

6262
Assert.That(mergeRequests, Has.Length.EqualTo(1), "Merge requests count is invalid");
6363
Assert.That(mergeRequests[0].Title, Is.EqualTo("Merge request 2"), "Merge request found is invalid");

NGitLab.Mock.Tests/MilestonesMockTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public void Test_milestones_can_be_closed_and_activated_from_project()
103103
[Test]
104104
public void Test_projects_merge_request_can_be_found_from_milestone()
105105
{
106-
const int ProjectId = 1;
107-
const int MilestoneId = 1;
106+
const long ProjectId = 1;
107+
const long MilestoneId = 1;
108108
using var server = new GitLabConfig()
109109
.WithUser("user1", isDefault: true)
110110
.WithProject("Test", id: ProjectId, addDefaultUserAsMaintainer: true, configure: project => project
@@ -122,8 +122,8 @@ public void Test_projects_merge_request_can_be_found_from_milestone()
122122
[Test]
123123
public void Test_groups_merge_request_can_be_found_from_milestone()
124124
{
125-
const int projectId = 1;
126-
const int milestoneId = 1;
125+
const long projectId = 1;
126+
const long milestoneId = 1;
127127
using var server = new GitLabConfig()
128128
.WithUser("user1", isDefault: true)
129129
.WithGroup("parentGroup", id: projectId, configure: group => group

NGitLab.Mock.Tests/ProjectsMockTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Globalization;
33
using System.IO;
4+
using System.Linq;
45
using System.Net;
56
using System.Threading.Tasks;
67
using FluentAssertions;
@@ -213,7 +214,7 @@ public async Task CreateAsync_WhenMockCreatedWithSupportedOptions_TheyAreAvailab
213214
{
214215
Name = "MyProject",
215216
Path = "my-project",
216-
NamespaceId = "my-group",
217+
NamespaceId = server.Groups.First(g => string.Equals(g.Name, "MyGroup", StringComparison.Ordinal)).Id,
217218
Description = "Description",
218219
DefaultBranch = "foo",
219220
InitializeWithReadme = true,
@@ -228,7 +229,7 @@ public async Task CreateAsync_WhenMockCreatedWithSupportedOptions_TheyAreAvailab
228229
actual.Name.Should().Be(expected.Name);
229230
actual.Path.Should().Be(expected.Path);
230231
actual.Description.Should().Be(expected.Description);
231-
actual.Namespace.FullPath.Should().Be(expected.NamespaceId);
232+
actual.Namespace.Id.Should().Be(expected.NamespaceId);
232233
actual.NameWithNamespace.Should().Be($"MyGroup / {expected.Name}");
233234
actual.PathWithNamespace.Should().Be($"my-group/{expected.Path}");
234235
actual.DefaultBranch.Should().Be(expected.DefaultBranch);

NGitLab.Mock/Badge.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace NGitLab.Mock;
44

55
public sealed class Badge : GitLabObject
66
{
7-
public int Id { get; set; }
7+
public long Id { get; set; }
88

99
public string LinkUrl { get; set; }
1010

NGitLab.Mock/BadgeCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public BadgeCollection(GitLabObject parent)
1010
{
1111
}
1212

13-
public Badge GetById(int id)
13+
public Badge GetById(long id)
1414
{
1515
return this.FirstOrDefault(badge => badge.Id == id);
1616
}

NGitLab.Mock/Clients/BranchClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace NGitLab.Mock.Clients;
88

99
internal sealed class BranchClient : ClientBase, IBranchClient
1010
{
11-
private readonly int _projectId;
11+
private readonly long _projectId;
1212

13-
public BranchClient(ClientContext context, int projectId)
13+
public BranchClient(ClientContext context, long projectId)
1414
: base(context)
1515
{
1616
_projectId = projectId;

NGitLab.Mock/Clients/ClientBase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected Group GetGroup(object id, GroupPermission permissions)
3030

3131
var group = id switch
3232
{
33-
int idInt => Server.AllGroups.FindById(idInt),
33+
long idLong => Server.AllGroups.FindById(idLong),
3434
string idStr => Server.AllGroups.FindGroup(idStr),
3535
IIdOrPathAddressable gid when gid.Path != null => Server.AllGroups.FindByNamespacedPath(gid.Path),
3636
IIdOrPathAddressable gid => Server.AllGroups.FindById(gid.Id),
@@ -78,7 +78,7 @@ protected Project GetProject(object id, ProjectPermission permissions)
7878

7979
var project = id switch
8080
{
81-
int idInt => Server.AllProjects.FindById(idInt),
81+
long idLong => Server.AllProjects.FindById(idLong),
8282
string idStr => Server.AllProjects.FindProject(idStr),
8383
IIdOrPathAddressable pid when pid.Path != null => Server.AllProjects.FindByNamespacedPath(pid.Path),
8484
IIdOrPathAddressable pid => Server.AllProjects.FindById(pid.Id),
@@ -116,7 +116,7 @@ protected Project GetProject(object id, ProjectPermission permissions)
116116
return project;
117117
}
118118

119-
protected User GetUser(int userId)
119+
protected User GetUser(long userId)
120120
{
121121
var user = Server.Users.GetById(userId);
122122
if (user == null)
@@ -125,7 +125,7 @@ protected User GetUser(int userId)
125125
return user;
126126
}
127127

128-
protected Issue GetIssue(int projectId, int issueId)
128+
protected Issue GetIssue(long projectId, long issueId)
129129
{
130130
var project = GetProject(projectId, ProjectPermission.View);
131131
var issue = project.Issues.GetByIid(issueId);
@@ -135,7 +135,7 @@ protected Issue GetIssue(int projectId, int issueId)
135135
return issue;
136136
}
137137

138-
protected Milestone GetMilestone(int projectId, int milestoneId)
138+
protected Milestone GetMilestone(long projectId, long milestoneId)
139139
{
140140
var project = GetProject(projectId, ProjectPermission.View);
141141
var milestone = project.Milestones.GetByIid(milestoneId);
@@ -145,7 +145,7 @@ protected Milestone GetMilestone(int projectId, int milestoneId)
145145
return milestone;
146146
}
147147

148-
protected MergeRequest GetMergeRequest(int projectId, int mergeRequestIid)
148+
protected MergeRequest GetMergeRequest(long projectId, long mergeRequestIid)
149149
{
150150
var project = GetProject(projectId, ProjectPermission.View);
151151
var mergeRequest = project.MergeRequests.GetByIid(mergeRequestIid);

NGitLab.Mock/Clients/ClusterClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace NGitLab.Mock.Clients;
66

77
internal sealed class ClusterClient : ClientBase, IClusterClient
88
{
9-
private readonly int _projectId;
9+
private readonly long _projectId;
1010

1111
public ClusterClient(ClientContext context, ProjectId projectId)
1212
: base(context)

NGitLab.Mock/Clients/CommitClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace NGitLab.Mock.Clients;
77

88
internal sealed class CommitClient : ClientBase, ICommitClient
99
{
10-
private readonly int _projectId;
10+
private readonly long _projectId;
1111

1212
public CommitClient(ClientContext context, ProjectId projectId)
1313
: base(context)

0 commit comments

Comments
 (0)