-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added code to sanitize Partition- and Rowkeys. Refactored to use buil…
…ders for LatestReleases/Publications.
- Loading branch information
1 parent
7ade736
commit 0c36335
Showing
13 changed files
with
193 additions
and
57 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
25 changes: 25 additions & 0 deletions
25
src/AzureFunctionsUpdates.UnitTests/Storage/KeyFormatterTests.cs
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,25 @@ | ||
using AzureFunctionsUpdates.Storage; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace AzureFunctionsUpdates.UnitTests.Storage | ||
{ | ||
public class KeyFormatterTests | ||
{ | ||
[Theory] | ||
[InlineData("abcd123", "abcd123")] | ||
[InlineData("abcd-123", "abcd-123")] | ||
[InlineData("abcd?123", "abcd-123")] | ||
[InlineData("abcd#123#", "abcd-123-")] | ||
[InlineData("abcd/123", "abcd-123")] | ||
[InlineData("abcd\\1?2#3", "abcd-1-2-3")] | ||
public void SanitizeKeyTests(string oldKey, string newKey) | ||
{ | ||
// Act | ||
var result = KeyFormatter.SanitizeKey(oldKey); | ||
|
||
// Assert | ||
result.Should().Be(newKey); | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/AzureFunctionsUpdates/Builders/LatestObjectsBuilder.cs
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,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using AzureFunctionsUpdates.Models.RepositoryReleases; | ||
|
||
namespace AzureFunctionsUpdates.Builders | ||
{ | ||
public static class LatestObjectsBuilder | ||
{ | ||
public static TLatest Build<TConfiguration, TMonitored, TLatest>( | ||
TConfiguration configuration, | ||
IEnumerable<TMonitored> newObjects, | ||
IEnumerable<TMonitored> historicalObjects, | ||
Func<TConfiguration, TMonitored, bool> matchObject) where TLatest : new() | ||
{ | ||
var latestNew = newObjects.First(obj => matchObject(configuration, obj)); | ||
var latestHistorical = historicalObjects.First(obj => matchObject(configuration, obj)); | ||
|
||
return (TLatest)Activator.CreateInstance(typeof(TLatest), latestNew, latestHistorical); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/AzureFunctionsUpdates/Builders/PublicationFunctionBuilder.cs
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,14 @@ | ||
using System; | ||
using AzureFunctionsUpdates.Models.Publications; | ||
using AzureFunctionsUpdates.Models.RepositoryReleases; | ||
|
||
namespace AzureFunctionsUpdates.Builders | ||
{ | ||
public static class PublicationFunctionBuilder | ||
{ | ||
public static Func<PublicationConfiguration, Publication, bool> BuildForMatchingPublicationSource() | ||
{ | ||
return (config, publication) => publication.PublicationSourceName.Equals(config.PublicationSourceName, StringComparison.InvariantCultureIgnoreCase); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/AzureFunctionsUpdates/Builders/ReleaseFunctionBuilder.cs
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,13 @@ | ||
using System; | ||
using AzureFunctionsUpdates.Models.RepositoryReleases; | ||
|
||
namespace AzureFunctionsUpdates.Builders | ||
{ | ||
public static class ReleaseFunctionBuilder | ||
{ | ||
public static Func<RepositoryConfiguration, RepositoryRelease, bool> BuildForMatchingRepositoryName() | ||
{ | ||
return (config, release) => release.RepositoryName.Equals(config.RepositoryName, StringComparison.InvariantCultureIgnoreCase); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.