-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support search branches * Add tests for `BranchClient.Search` * Improve tests for `BranchClient.Search`
- Loading branch information
Showing
6 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Linq; | ||
using NGitLab.Mock.Config; | ||
using NUnit.Framework; | ||
|
||
namespace NGitLab.Mock.Tests | ||
{ | ||
public class BranchesMockTests | ||
{ | ||
[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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters