Skip to content

Commit

Permalink
Parameterize Index_sort_order test to verify other index AMs
Browse files Browse the repository at this point in the history
  • Loading branch information
khellang committed Feb 20, 2019
1 parent 0e6d61e commit a7016f0
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1433,20 +1433,29 @@ public void Index_collation()
},
@"DROP TABLE ""IndexCollation""");

[Fact]
public void Index_sort_order()
[Theory]
[InlineData("gin", null)]
[InlineData("gist", null)]
[InlineData("hash", null)]
[InlineData("brin", null)]
[InlineData("btree", new[] { SortOrder.Ascending, SortOrder.Descending })]
public void Index_sort_order(string method, SortOrder[] expected)
=> Test(@"
CREATE TABLE ""IndexSortOrder"" (a text, b text);
CREATE INDEX ix_with ON ""IndexSortOrder"" (a DESC, b ASC);
CREATE TABLE ""IndexSortOrder"" (a text, b text, c tsvector);
CREATE INDEX ix_gin ON ""IndexSortOrder"" USING gin (c);
CREATE INDEX ix_gist ON ""IndexSortOrder"" USING gist (c);
CREATE INDEX ix_hash ON ""IndexSortOrder"" USING hash (a);
CREATE INDEX ix_brin ON ""IndexSortOrder"" USING brin (a);
CREATE INDEX ix_btree ON ""IndexSortOrder"" USING btree (a ASC, b DESC);
CREATE INDEX ix_without ON ""IndexSortOrder"" (a, b);",
Enumerable.Empty<string>(),
Enumerable.Empty<string>(),
dbModel =>
{
var table = dbModel.Tables.Single();
var indexWith = table.Indexes.Single(i => i.Name == "ix_with");
Assert.Equal(new[] { SortOrder.Descending, SortOrder.Ascending }, indexWith.FindAnnotation(NpgsqlAnnotationNames.IndexSortOrder).Value);
var indexWith = table.Indexes.Single(i => i.Name == $"ix_{method}");
Assert.Equal(expected, indexWith.FindAnnotation(NpgsqlAnnotationNames.IndexSortOrder)?.Value);
var indexWithout = table.Indexes.Single(i => i.Name == "ix_without");
Assert.Null(indexWithout.FindAnnotation(NpgsqlAnnotationNames.IndexSortOrder));
Expand Down

0 comments on commit a7016f0

Please sign in to comment.