-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add goal Review Deferred Duplicates to handle skipped merge sets (#2610)
Co-authored-by: D. Ror <[email protected]>
- Loading branch information
1 parent
1d09bc3
commit a9c0f82
Showing
45 changed files
with
1,167 additions
and
186 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 |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
"Dups", | ||
"endcap", | ||
"globaltool", | ||
"graylist", | ||
"Guids", | ||
"kubeconfig", | ||
"langtags", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using BackendFramework.Helper; | ||
using BackendFramework.Interfaces; | ||
using BackendFramework.Models; | ||
|
||
namespace Backend.Tests.Mocks | ||
{ | ||
public class MergeGraylistRepositoryMock : IMergeGraylistRepository | ||
{ | ||
private readonly List<MergeWordSet> _mergeGraylist; | ||
|
||
public MergeGraylistRepositoryMock() | ||
{ | ||
_mergeGraylist = new List<MergeWordSet>(); | ||
} | ||
|
||
public Task<List<MergeWordSet>> GetAllSets(string projectId, string? userId = null) | ||
{ | ||
var cloneList = _mergeGraylist.Select(e => e.Clone()).ToList(); | ||
var enumerable = userId is null ? | ||
cloneList.Where(e => e.ProjectId == projectId) : | ||
cloneList.Where(e => e.ProjectId == projectId && e.UserId == userId); | ||
return Task.FromResult(enumerable.ToList()); | ||
} | ||
|
||
public Task<MergeWordSet?> GetSet(string projectId, string entryId) | ||
{ | ||
try | ||
{ | ||
var foundMergeGraylist = _mergeGraylist.Single(entry => entry.Id == entryId); | ||
return Task.FromResult<MergeWordSet?>(foundMergeGraylist.Clone()); | ||
} | ||
catch (InvalidOperationException) | ||
{ | ||
return Task.FromResult<MergeWordSet?>(null); | ||
} | ||
} | ||
|
||
public Task<MergeWordSet> Create(MergeWordSet wordSetEntry) | ||
{ | ||
wordSetEntry.Id = Guid.NewGuid().ToString(); | ||
_mergeGraylist.Add(wordSetEntry.Clone()); | ||
return Task.FromResult(wordSetEntry.Clone()); | ||
} | ||
|
||
public Task<bool> DeleteAllSets(string projectId) | ||
{ | ||
_mergeGraylist.Clear(); | ||
return Task.FromResult(true); | ||
} | ||
|
||
public Task<bool> Delete(string projectId, string entryId) | ||
{ | ||
var foundMergeGraylist = _mergeGraylist.Single(entry => entry.Id == entryId); | ||
return Task.FromResult(_mergeGraylist.Remove(foundMergeGraylist)); | ||
} | ||
|
||
public Task<ResultOfUpdate> Update(MergeWordSet wordSetEntry) | ||
{ | ||
var foundEntry = _mergeGraylist.Single( | ||
e => e.ProjectId == wordSetEntry.ProjectId && e.Id == wordSetEntry.Id); | ||
var success = _mergeGraylist.Remove(foundEntry); | ||
if (!success) | ||
{ | ||
return Task.FromResult(ResultOfUpdate.NotFound); | ||
} | ||
|
||
_mergeGraylist.Add(wordSetEntry.Clone()); | ||
return Task.FromResult(ResultOfUpdate.Updated); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.