Skip to content
This repository has been archived by the owner on Jun 14, 2022. It is now read-only.

Commit

Permalink
Fulltext indexes with parsers: add unit test coverage
Browse files Browse the repository at this point in the history
Recent commit 6d71ca0 added support for WITH PARSER clauses of fulltext
indexes. It included an integration test for MySQL 5.7+, but did not include
a unit test. This commit adds the missing unit test, which works regardless
of flavor.
  • Loading branch information
evanelias committed Apr 21, 2020
1 parent 02c97f1 commit d7318c1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,3 +931,29 @@ func TestFixColumnCompression(t *testing.T) {
t.Errorf("Unexpected mismatch in generated CREATE TABLE:\nGeneratedCreateStatement:\n%s\nCreateStatement:\n%s", table.GeneratedCreateStatement(FlavorPercona57), table.CreateStatement)
}
}

// TestFixFulltextIndexParsers confirms CREATE TABLE parsing for WITH PARSER
// clauses works properly.
func TestFixFulltextIndexParsers(t *testing.T) {
table := anotherTableForFlavor(FlavorMySQL57)
if table.SecondaryIndexes[0].Type != "BTREE" || table.SecondaryIndexes[0].FullTextParser != "" {
t.Fatal("Test fixture has changed without corresponding update to this test's logic")
}

// Confirm no parser = no change from fix
table.SecondaryIndexes[0].Type = "FULLTEXT"
table.CreateStatement = table.GeneratedCreateStatement(FlavorMySQL57)
fixFulltextIndexParsers(&table, FlavorMySQL57)
if table.SecondaryIndexes[0].FullTextParser != "" {
t.Errorf("fixFulltextIndexParsers unexpectedly set parser to %q instead of %q", table.SecondaryIndexes[0].FullTextParser, "")
}

// Confirm parser extracted correctly from fix
table.SecondaryIndexes[0].FullTextParser = "ngram"
table.CreateStatement = table.GeneratedCreateStatement(FlavorMySQL57)
table.SecondaryIndexes[0].FullTextParser = ""
fixFulltextIndexParsers(&table, FlavorMySQL57)
if table.SecondaryIndexes[0].FullTextParser != "ngram" {
t.Errorf("fixFulltextIndexParsers unexpectedly set parser to %q instead of %q", table.SecondaryIndexes[0].FullTextParser, "ngram")
}
}

0 comments on commit d7318c1

Please sign in to comment.