Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion PatchPanda.Units/Helpers/ParsingHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public async Task SetGitHubRepo_CollapsesDifferentCandidates_WhenReleaseUrlsMatc
var response = new ContainerListResponse
{
Image =
$"ghcr.io/{TestData.GITHUB_OWNER}/{TestData.GITHUB_REPO}:1.0,https://github.com/{TestData.OWNER_B}/{TestData.REPO_B}"
$"ghcr.io/{TestData.GITHUB_OWNER}/{TestData.GITHUB_REPO}:1.0,https://github.com/{TestData.OWNER_B}/{TestData.REPO_B}",
};

var sharedRelease = CreateRelease(TestData.RELEASE_TAG, TestData.GITHUB_URL);
Expand Down Expand Up @@ -212,6 +212,45 @@ public async Task SetGitHubRepo_CollapsesDifferentCandidates_WhenReleaseUrlsMatc
);
}

[Fact]
public async Task SetGitHubRepo_SetsRepo_WhenRepositoryContainsDot()
{
var image = $"ghcr.io/{TestData.DOT_OWNER}/{TestData.DOT_REPO}:{TestData.VERSION}";
var repoUrl = $"https://github.com/{TestData.DOT_OWNER}/{TestData.DOT_REPO}";

var stack = Helper.GetTestStack(TestData.VERSION, null, image);
var container = stack.Apps[0];

var response = new ContainerListResponse { Image = image };

var release = CreateRelease(TestData.NEW_VERSION, repoUrl);

var versionServiceMock = new Mock<IVersionService>();

versionServiceMock
.Setup(vs =>
vs.GetVersions(
It.Is<Tuple<string, string>>(t =>
t.Item1 == TestData.DOT_OWNER && t.Item2 == TestData.DOT_REPO
)
)
)
.ReturnsAsync([release]);

var logger = new Mock<ILogger>().Object;

await container.SetGitHubRepo(response, versionServiceMock.Object, logger);

Assert.Equal(
new Tuple<string, string>(TestData.DOT_OWNER, TestData.DOT_REPO),
container.GitHubRepo
);
Assert.Equal(
VersionHelper.BuildRegexFromVersion(TestData.NEW_VERSION),
container.GitHubVersionRegex
);
}

private static Release CreateRelease(string tagName, string url)
{
var relType = typeof(Release);
Expand Down
3 changes: 3 additions & 0 deletions PatchPanda.Units/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ public static class TestData
public const string RELEASE_TAG_A = "v1.0.0";
public const string RELEASE_TAG_B = "v2.0.0";
public const string ALPINE_IMAGE = "alpine:3.16";

public const string DOT_OWNER = "dgtlmoon";
public const string DOT_REPO = "changedetection.io";
}
6 changes: 3 additions & 3 deletions PatchPanda.Web/Helpers/ParsingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ ILogger logger

var githubMatches = Regex.Matches(
fullResponse,
@"https://github.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)"
@"https://github.com\/([a-zA-Z0-9_.-]+)\/([a-zA-Z0-9_.-]+)"
);

var ghcrMatches = Regex.Matches(
fullResponse,
@"ghcr.io\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)"
@"ghcr.io\/([a-zA-Z0-9_.-]+)\/([a-zA-Z0-9_.-]+)"
);

var imageMatches = Regex.Matches(response.Image, @"([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+):");
var imageMatches = Regex.Matches(response.Image, @"([a-zA-Z0-9_.-]+)\/([a-zA-Z0-9_.-]+):");

Dictionary<Tuple<string, string>, IReadOnlyList<Octokit.Release>> versionCounts = [];

Expand Down
Loading