Skip to content

Conversation

@elzik
Copy link
Owner

@elzik elzik commented Nov 30, 2025

Summary by CodeRabbit

  • Tests
    • Updated end-to-end testing infrastructure to support parameterized test execution with multiple URL configurations.
    • Enhanced test environment-specific skip conditions for improved CI/CD compatibility.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 30, 2025

Walkthrough

A single test method is refactored from a parameterless fact-based test to a parameterized theory test accepting multiple URL inputs. Skip logic is enhanced to conditionally assess GitHub Actions environment and URL context, with the test now using provided URLs instead of hardcoded values.

Changes

Cohort / File(s) Summary
Test Method Parameterization and Skip Logic
tests/Elzik.Breef.Api.Tests.Functional/Breefs/BreefTestsBase.cs
EndToEndHappyPath() converted from [SkippableFact] to [SkippableTheory] accepting string url parameter with multiple InlineData sources. Skip condition logic expanded to evaluate GitHub Actions environment and URL context, conditionally updating SkipTestsReason when targeting reddit.com in workflows. Test now uses provided url variable instead of hardcoded http://example.com. SkipTestsReason property modified to include private setter.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify xUnit theory parameterization and InlineData configuration are correct
  • Review the conditional skip logic for GitHub Actions environment detection and URL-specific handling
  • Ensure property setter change maintains expected visibility and usage patterns across derived test classes
  • Confirm all provided URLs are intentional test targets

Poem

🐰 A test that once stood alone and proud,
Now dances with companions through the cloud!
URLs multiply like carrots in spring,
While skip conditions make their judgment ring—
From fact to theory, we bound and leap!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Limit Period for Subreddits' is vague and does not clearly reflect the actual changes made to the codebase. Consider a more descriptive title that clarifies the specific changes, such as 'Parameterize EndToEndHappyPath test with URL variations' or 'Add URL-based skip logic for Reddit integration tests'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch limit-subreddit-period

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@elzik elzik changed the title Limit Period for Reddit Posts Limit Period for Subreddits Nov 30, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/Elzik.Breef.Api.Tests.Functional/Breefs/BreefTestsBase.cs (1)

20-20: Consider reverting the setter if the mutation is removed.

If you adopt the local variable approach suggested for lines 47-57, the private setter added to SkipTestsReason becomes unnecessary, and the property can remain read-only.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce5b950 and 54fbcd8.

📒 Files selected for processing (1)
  • tests/Elzik.Breef.Api.Tests.Functional/Breefs/BreefTestsBase.cs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build-ubuntu
  • GitHub Check: Analyze (csharp)
  • GitHub Check: build-ubuntu
🔇 Additional comments (2)
tests/Elzik.Breef.Api.Tests.Functional/Breefs/BreefTestsBase.cs (2)

41-45: Parameterization looks good.

The conversion from [SkippableFact] to [SkippableTheory] with multiple URL test cases is appropriate for testing both regular URLs and Reddit-specific behavior.


60-60: LGTM!

The URL parameter is correctly used in the test payload, enabling the parameterized test to work with different URLs.

Comment on lines +47 to +57
var attemptingRedditTestInGithubWorklow =
url.StartsWith("https://www.reddit.com") &&
Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true";
var skipTest = SkipTestsIf || attemptingRedditTestInGithubWorklow;
if(attemptingRedditTestInGithubWorklow)
{
SkipTestsReason = "Skipped because requests to reddit.com from GitHub workflows are " +
"always blocked meaning this test case always fails. This must be run locally instead.";
}

Skip.If(skipTest, SkipTestsReason);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Race condition: mutating shared property in parameterized test.

Modifying SkipTestsReason (line 53) within a theory test creates a race condition because xUnit runs theory tests in parallel by default. Multiple test instances can overwrite each other's skip reasons, leading to incorrect or misleading skip messages.

Recommended solution: Use a local variable for the skip reason instead:

         [SkippableTheory]
         [InlineData("http://example.com")]
         [InlineData("https://www.reddit.com/r/dotnet/")]
         [InlineData("https://www.reddit.com/r/selfhosted/comments/1ojndg6/advice_should_i_buy_a_new_router_or_build_one/")]
         public async Task EndToEndHappyPath(string url)
         {
             var attemptingRedditTestInGithubWorklow = 
                 url.StartsWith("https://www.reddit.com") && 
                 Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true";
             var skipTest = SkipTestsIf || attemptingRedditTestInGithubWorklow;
+            var skipReason = SkipTestsReason;
             if(attemptingRedditTestInGithubWorklow)
             {
-                SkipTestsReason = "Skipped because requests to reddit.com from GitHub workflows are " +
+                skipReason = "Skipped because requests to reddit.com from GitHub workflows are " +
                     "always blocked meaning this test case always fails. This must be run locally instead.";
             }
             
-            Skip.If(skipTest, SkipTestsReason);
+            Skip.If(skipTest, skipReason);

Minor: Use case-insensitive URL comparison.

The url.StartsWith("https://www.reddit.com") check (line 48) is case-sensitive. For robustness, use case-insensitive comparison for the URL scheme and host:

-            var attemptingRedditTestInGithubWorklow = 
-                url.StartsWith("https://www.reddit.com") && 
-                Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true";
+            var attemptingRedditTestInGithubWorklow = 
+                url.StartsWith("https://www.reddit.com", StringComparison.OrdinalIgnoreCase) && 
+                Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var attemptingRedditTestInGithubWorklow =
url.StartsWith("https://www.reddit.com") &&
Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true";
var skipTest = SkipTestsIf || attemptingRedditTestInGithubWorklow;
if(attemptingRedditTestInGithubWorklow)
{
SkipTestsReason = "Skipped because requests to reddit.com from GitHub workflows are " +
"always blocked meaning this test case always fails. This must be run locally instead.";
}
Skip.If(skipTest, SkipTestsReason);
var attemptingRedditTestInGithubWorklow =
url.StartsWith("https://www.reddit.com") &&
Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true";
var skipTest = SkipTestsIf || attemptingRedditTestInGithubWorklow;
var skipReason = SkipTestsReason;
if(attemptingRedditTestInGithubWorklow)
{
skipReason = "Skipped because requests to reddit.com from GitHub workflows are " +
"always blocked meaning this test case always fails. This must be run locally instead.";
}
Skip.If(skipTest, skipReason);
Suggested change
var attemptingRedditTestInGithubWorklow =
url.StartsWith("https://www.reddit.com") &&
Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true";
var skipTest = SkipTestsIf || attemptingRedditTestInGithubWorklow;
if(attemptingRedditTestInGithubWorklow)
{
SkipTestsReason = "Skipped because requests to reddit.com from GitHub workflows are " +
"always blocked meaning this test case always fails. This must be run locally instead.";
}
Skip.If(skipTest, SkipTestsReason);
var attemptingRedditTestInGithubWorklow =
url.StartsWith("https://www.reddit.com", StringComparison.OrdinalIgnoreCase) &&
Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true";
var skipTest = SkipTestsIf || attemptingRedditTestInGithubWorklow;
if(attemptingRedditTestInGithubWorklow)
{
SkipTestsReason = "Skipped because requests to reddit.com from GitHub workflows are " +
"always blocked meaning this test case always fails. This must be run locally instead.";
}
Skip.If(skipTest, SkipTestsReason);
🤖 Prompt for AI Agents
In tests/Elzik.Breef.Api.Tests.Functional/Breefs/BreefTestsBase.cs around lines
47 to 57, avoid mutating the shared property SkipTestsReason inside the
parameterized/theory test to prevent race conditions: create a local variable
(e.g., localSkipReason) and set that when computing whether to skip, then pass
that local variable into Skip.If; also make the reddit URL check
case-insensitive (e.g., use StartsWith with an OrdinalIgnoreCase comparison or
parse the URL and compare the scheme/host case-insensitively) so the detection
is robust.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants