GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
705 B

  1. package postgres
  2. import (
  3. "fmt"
  4. "github.com/stretchr/testify/assert"
  5. "testing"
  6. )
  7. func TestTSQueryFromSearch(t *testing.T) {
  8. rows := [][2]string{
  9. {`asari matron`, `asari & matron`},
  10. {`"asari matron"`, `(asari<->matron)`},
  11. {`"asari matron" blue`, `(asari<->matron) & blue`},
  12. {`"christmas present" "wrapping paper"`, `(christmas<->present) & (wrapping<->paper)`},
  13. {`stuff`, `stuff`},
  14. {`"stuff"`, `stuff`},
  15. {`"her slowly, rubbing the back of his head awkwardly. "`, `(her<->slowly<->rubbing<->the<->back<->of<->his<->head<->awkwardly)`},
  16. }
  17. for i, row := range rows {
  18. t.Run(fmt.Sprintf("Row_%d", i), func(t *testing.T) {
  19. assert.Equal(t, row[1], TSQueryFromSearch(row[0]))
  20. })
  21. }
  22. }