Skip to content

Commit

Permalink
BREAKING CHANGE: Allow tag name to be case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDave1999 committed Jul 6, 2024
1 parent 4945482 commit 6206d30
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Reader/YeSqlDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class YeSqlDictionary : ISqlCollection
/// <summary>
/// A dictionary containing the SQL statements that have been parsed from the data source (e.g., a SQL file).
/// </summary>
private readonly Dictionary<string, string> _sqlStatements = [];
private readonly Dictionary<string, string> _sqlStatements = new(StringComparer.OrdinalIgnoreCase);

/// <inheritdoc />
public string this[string tagName]
Expand Down
22 changes: 22 additions & 0 deletions tests/Parser/YeSqlParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ public void Parse_WhenDataSourceIsEmptyOrWithWhitespace_ShouldReturnsEmptyCollec
validationResult.ErrorMessages.Should().Contain(expectedMessage);
}

[Test]
public void Parse_WhenTagNameIsCaseInsensitive_ShouldReturnsSqlStatements()
{
// Arrange
var parser = new YeSqlParser();
var expectedSqlStatement = "SELECT * FROM users;" + Environment.NewLine;
var source =
"""
-- name: GetUsers
SELECT * FROM users;
""";

// Act
ISqlCollection sqlStatements = parser.Parse(source, out _);

// Asserts
sqlStatements["GetUsers"].Should().Be(expectedSqlStatement);
sqlStatements["getUsers"].Should().Be(expectedSqlStatement);
sqlStatements["getusers"].Should().Be(expectedSqlStatement);
sqlStatements["GETUSERS"].Should().Be(expectedSqlStatement);
}

[TestCaseSource(typeof(TagIsEmptyOrWhitespaceTestCases))]
public void Parse_WhenTagIsEmptyOrConsistsOnlyOfWhitespaces_ShouldGenerateAnError(
string source,
Expand Down

0 comments on commit 6206d30

Please sign in to comment.