hotword_test.go 671 B

123456789101112131415161718192021222324252627282930313233
  1. package goblin
  2. import (
  3. "testing"
  4. "context"
  5. "go-common/app/interface/main/tv/model"
  6. "go-common/library/cache/memcache"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDao_Hotword(t *testing.T) {
  10. Convey("Hotword Test", t, WithDao(func(d *Dao) {
  11. ctx := context.TODO()
  12. conn := d.mc.Get(ctx)
  13. s := []*model.Hotword{
  14. {
  15. Keyword: "Test1",
  16. },
  17. {
  18. Keyword: "Test2",
  19. },
  20. }
  21. defer conn.Close()
  22. err := conn.Set(&memcache.Item{Key: _hotwordKey, Object: s, Flags: memcache.FlagJSON, Expiration: 1200})
  23. So(err, ShouldBeNil)
  24. hotwordList, err := d.Hotword(ctx)
  25. So(err, ShouldBeNil)
  26. So(len(hotwordList), ShouldBeGreaterThan, 0)
  27. }))
  28. }