2020-03-25 16:33:32 -08:00
|
|
|
package persistence
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/Masterminds/squirrel"
|
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var _ = Describe("Helpers", func() {
|
|
|
|
|
Describe("Exists", func() {
|
|
|
|
|
It("constructs the correct EXISTS query", func() {
|
2020-05-01 05:17:21 -08:00
|
|
|
e := exists("album", squirrel.Eq{"id": 1})
|
2020-03-25 16:33:32 -08:00
|
|
|
sql, args, err := e.ToSql()
|
|
|
|
|
Expect(sql).To(Equal("exists (select 1 from album where id = ?)"))
|
|
|
|
|
Expect(args).To(Equal([]interface{}{1}))
|
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|