(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestAliasOrIdentifier(t *testing.T) { |
| 10 | scenarios := []struct { |
| 11 | value string |
| 12 | expected string |
| 13 | }{ |
| 14 | {"", ""}, |
| 15 | {"abc", "abc"}, |
| 16 | {"abc ", "abc "}, // return unmodified |
| 17 | {"abc.def", "abc.def"}, |
| 18 | {"abc.123 def", "def"}, |
| 19 | {"abc.123 as def.456", "def.456"}, |
| 20 | {"(abc) def", "def"}, |
| 21 | {"(abc) as def", "def"}, |
| 22 | {"abc def", "def"}, |
| 23 | {"abc as def", "def"}, |
| 24 | // technically invalid identifier but consistent with the dbx regex matching |
| 25 | {"a b c d", "d"}, |
| 26 | {"a b c as d", "d"}, |
| 27 | } |
| 28 | |
| 29 | for _, s := range scenarios { |
| 30 | t.Run(s.value, func(t *testing.T) { |
| 31 | result := dbutils.AliasOrIdentifier(s.value) |
| 32 | |
| 33 | if result != s.expected { |
| 34 | t.Fatalf("Expected\n%v\ngot\n%v", s.expected, result) |
| 35 | } |
| 36 | }) |
| 37 | } |
| 38 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…