Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make semver logging actually log context value that failed parsing #200

Merged
merged 1 commit into from
Jan 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public bool Evaluate(Constraint constraint, UnleashContext context)
SemanticVersion contextSemver;
if (!SemanticVersion.TryParse(contextValue, out contextSemver))
{
Logger.Info(() => "Couldn't parse version {0} from context");
Logger.Info(() => $"Couldn't parse version {contextValue} from context");
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,27 @@ public void Release_Is_Greater_Than_RC_Inverted()
// Assert
result.Should().BeFalse();
}

[Test]
public void SemverConstraint_Handles_Invalid_Semver_Without_Raising_Exception()
{
// Arrange
var target = new SemverConstraintOperator();
var constraint = new Constraint(
"operator_semver_test",
Operator.SEMVER_GT,
false,
true,
"definitely.not.a.valid.semver"
);
var context = new UnleashContext();
context.Properties.Add("operator_semver_test", "also.definitely.not.a.semver");

// Act + Assert
Assert.DoesNotThrow(() =>
{
target.Evaluate(constraint, context);
});
}
}
}
Loading