emoji_package_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDao_EmojiPack(t *testing.T) {
  8. Convey("CreateEmojiPackage", t, WithDao(func(d *Dao) {
  9. id, err := d.CreateEmojiPackage(context.Background(), "[2233娘]", "www.baidu.com", 0, "", 1)
  10. So(err, ShouldBeNil)
  11. So(id, ShouldNotEqual, 0)
  12. d.DelEmojiPackage(context.Background(), id)
  13. }))
  14. Convey("EmojiPackageList", t, WithDao(func(d *Dao) {
  15. packs, err := d.EmojiPackageList(context.Background())
  16. So(err, ShouldBeNil)
  17. for _, v := range packs {
  18. t.Logf("v.Id= %d, v.Name= %s, v.Url= %s, v.Remark= %s, v.State= %d, v.Sort= %d",
  19. v.ID, v.Name, v.URL, v.Remark, v.State, v.Sort)
  20. }
  21. }))
  22. Convey("UpEmojiPackage", t, WithDao(func(d *Dao) {
  23. id, err := d.UpEmojiPackage(context.Background(), "[小电视x]", "xxxx", "xx", 1, 1)
  24. So(err, ShouldBeNil)
  25. t.Logf("id= %d", id)
  26. }))
  27. Convey("UpEmojiPackageSort", t, WithDao(func(d *Dao) {
  28. tx, _ := d.BeginTran(context.Background())
  29. err := d.UpEmojiPackageSort(tx, "1")
  30. if err != nil {
  31. tx.Rollback()
  32. t.Errorf("UpEmojiPackageSort err (%v)", err)
  33. return
  34. }
  35. tx.Commit()
  36. }))
  37. }