package postgres import ( "fmt" "github.com/stretchr/testify/assert" "testing" ) func TestTSQueryFromSearch(t *testing.T) { rows := [][2]string{ {`asari matron`, `asari & matron`}, {`"asari matron"`, `(asari<->matron)`}, {`"asari matron" blue`, `(asari<->matron) & blue`}, {`"christmas present" "wrapping paper"`, `(christmas<->present) & (wrapping<->paper)`}, {`stuff`, `stuff`}, {`"her slowly, rubbing the back of his head awkwardly. "`, `(her<->slowly<->rubbing<->the<->back<->of<->his<->head<->awkwardly)`}, } for i, row := range rows { t.Run(fmt.Sprintf("Row_%d", i), func(t *testing.T) { assert.Equal(t, row[1], TSQueryFromSearch(row[0])) }) } }