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.

23 lines
548 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. }
  15. for i, row := range rows {
  16. t.Run(fmt.Sprintf("Row_%d", i), func(t *testing.T) {
  17. assert.Equal(t, row[1], TSQueryFromSearch(row[0]))
  18. })
  19. }
  20. }