Skip to content

Commit

Permalink
Renamed "EnumTypesInconsistentRule" to "EnumValuesMismatchRule"
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-84 committed Jan 7, 2025
1 parent 85ead14 commit 002bd0e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace HotChocolate.Fusion.Logging;
public static class LogEntryCodes
{
public const string DisallowedInaccessible = "DISALLOWED_INACCESSIBLE";
public const string EnumTypesInconsistent = "ENUM_TYPES_INCONSISTENT";
public const string EnumValuesMismatch = "ENUM_VALUES_MISMATCH";
public const string ExternalArgumentDefaultMismatch = "EXTERNAL_ARGUMENT_DEFAULT_MISMATCH";
public const string ExternalMissingOnBase = "EXTERNAL_MISSING_ON_BASE";
public const string ExternalOnInterface = "EXTERNAL_ON_INTERFACE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,18 @@ public static LogEntry DisallowedInaccessibleDirectiveArgument(
schema);
}

public static LogEntry EnumTypesInconsistent(
public static LogEntry EnumValuesMismatch(
EnumTypeDefinition enumType,
string enumValue,
SchemaDefinition schema)
{
return new LogEntry(
string.Format(
LogEntryHelper_EnumTypesInconsistent,
LogEntryHelper_EnumValuesMismatch,
enumType.Name,
schema.Name,
enumValue),
LogEntryCodes.EnumTypesInconsistent,
LogEntryCodes.EnumValuesMismatch,
LogSeverity.Error,
new SchemaCoordinate(enumType.Name),
enumType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace HotChocolate.Fusion.PreMergeValidation.Rules;
/// exact match in their values.
/// </para>
/// </summary>
/// <seealso href="https://graphql.github.io/composite-schemas-spec/draft/#sec-Enum-Types-Inconsistent">
/// <seealso href="https://graphql.github.io/composite-schemas-spec/draft/#sec-Enum-Values-Mismatch">
/// Specification
/// </seealso>
internal sealed class EnumTypesInconsistentRule : IEventHandler<EnumTypeGroupEvent>
internal sealed class EnumValuesMismatchRule : IEventHandler<EnumTypeGroupEvent>
{
public void Handle(EnumTypeGroupEvent @event, CompositionContext context)
{
Expand All @@ -44,8 +44,7 @@ public void Handle(EnumTypeGroupEvent @event, CompositionContext context)
{
if (!enumType.Values.ContainsName(enumValue))
{
context.Log.Write(
EnumTypesInconsistent(enumType, enumValue, schema));
context.Log.Write(EnumValuesMismatch(enumType, enumValue, schema));
}
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<data name="LogEntryHelper_DisallowedInaccessibleDirectiveArgument" xml:space="preserve">
<value>The built-in directive argument '{0}' in schema '{1}' is not accessible.</value>
</data>
<data name="LogEntryHelper_EnumTypesInconsistent" xml:space="preserve">
<data name="LogEntryHelper_EnumValuesMismatch" xml:space="preserve">
<value>The enum type '{0}' in schema '{1}' must define the value '{2}'.</value>
</data>
<data name="LogEntryHelper_ExternalArgumentDefaultMismatch" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private CompositionResult<SchemaDefinition> MergeSchemaDefinitions(CompositionCo
private static readonly List<object> _preMergeValidationRules =
[
new DisallowedInaccessibleElementsRule(),
new EnumTypesInconsistentRule(),
new EnumValuesMismatchRule(),
new ExternalArgumentDefaultMismatchRule(),
new ExternalMissingOnBaseRule(),
new ExternalOnInterfaceRule(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace HotChocolate.Composition.PreMergeValidation.Rules;

public sealed class EnumTypesInconsistentRuleTests : CompositionTestBase
public sealed class EnumValuesMismatchRuleTests : CompositionTestBase
{
private readonly PreMergeValidator _preMergeValidator = new([new EnumTypesInconsistentRule()]);
private readonly PreMergeValidator _preMergeValidator = new([new EnumValuesMismatchRule()]);

[Theory]
[MemberData(nameof(ValidExamplesData))]
Expand Down Expand Up @@ -36,7 +36,7 @@ public void Examples_Invalid(string[] sdl, string[] errorMessages)
// assert
Assert.True(result.IsFailure);
Assert.Equal(errorMessages, context.Log.Select(e => e.Message).ToArray());
Assert.True(context.Log.All(e => e.Code == "ENUM_TYPES_INCONSISTENT"));
Assert.True(context.Log.All(e => e.Code == "ENUM_VALUES_MISMATCH"));
Assert.True(context.Log.All(e => e.Severity == LogSeverity.Error));
}

Expand Down

0 comments on commit 002bd0e

Please sign in to comment.