jointly_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "math/rand"
  6. "testing"
  7. "time"
  8. "go-common/app/admin/main/vip/model"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. // go test -test.v -test.run TestDaoAddJointly
  12. func TestDaoAddJointly(t *testing.T) {
  13. Convey("TestDaoAddJointly", t, func() {
  14. a, err := d.AddJointly(context.TODO(), &model.Jointly{
  15. Title: "这条是有效的,并且不 hot",
  16. Content: "这叫副标题?",
  17. Operator: "admin",
  18. StartTime: 1533202903,
  19. EndTime: 1543202904,
  20. Link: fmt.Sprintf("https://t.cn/%d", rand.Int63()),
  21. IsHot: 1,
  22. })
  23. So(err, ShouldBeNil)
  24. So(a, ShouldEqual, 1)
  25. })
  26. }
  27. // go test -test.v -test.run TestDaoUpdateJointly
  28. func TestDaoUpdateJointly(t *testing.T) {
  29. Convey("TestDaoUpdateJointly", t, func() {
  30. a, err := d.UpdateJointly(context.TODO(), &model.Jointly{
  31. Title: "这条是有效的,并且no hot",
  32. Content: "这叫副标题??",
  33. Operator: "admin2",
  34. Link: fmt.Sprintf("https://t.cn/%d", rand.Int63()),
  35. IsHot: 0,
  36. ID: 1,
  37. })
  38. So(err, ShouldBeNil)
  39. So(a, ShouldEqual, 1)
  40. })
  41. }
  42. // go test -test.v -test.run TestDaoJointlysByState
  43. func TestDaoJointlysByState(t *testing.T) {
  44. Convey("TestDaoJointlysByState", t, func() {
  45. res, err := d.JointlysByState(context.TODO(), 1, time.Now().Unix())
  46. t.Logf("count %+v", len(res))
  47. So(err, ShouldBeNil)
  48. })
  49. }
  50. // go test -test.v -test.run TestDaoDeleteJointly
  51. func TestDaoDeleteJointly(t *testing.T) {
  52. Convey("TestDaoDeleteJointly", t, func() {
  53. res, err := d.DeleteJointly(context.TODO(), 1)
  54. t.Logf("count %+v", res)
  55. So(res, ShouldBeGreaterThanOrEqualTo, 0)
  56. So(err, ShouldBeNil)
  57. })
  58. }