dao_test.go 1011 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package dao
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/job/main/stat/conf"
  8. "go-common/app/service/main/archive/api"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var d *Dao
  12. func init() {
  13. dir, _ := filepath.Abs("../cmd/stat-job-test.toml")
  14. flag.Set("conf", dir)
  15. conf.Init()
  16. d = New(conf.Conf)
  17. }
  18. func Test_SendQiyeWX(t *testing.T) {
  19. Convey("SendQiyeWX", t, func() {
  20. d.SendQiyeWX("日志报警:stat-job topic(test) 不消费了")
  21. })
  22. }
  23. func Test_Ping(t *testing.T) {
  24. Convey("Ping", t, func() {
  25. d.Ping(context.TODO())
  26. })
  27. }
  28. func Test_Stat(t *testing.T) {
  29. Convey("Stat", t, func() {
  30. st, err := d.Stat(context.TODO(), 10989901)
  31. So(err, ShouldBeNil)
  32. Printf("%+v", st)
  33. })
  34. }
  35. func Test_Update(t *testing.T) {
  36. Convey("Update", t, func() {
  37. _, err := d.Update(context.TODO(), &api.Stat{Aid: 10989901, Fav: 100, DisLike: 10, Like: 20})
  38. So(err, ShouldBeNil)
  39. })
  40. }
  41. func Test_MaxAID(t *testing.T) {
  42. Convey("MaxAID", t, func() {
  43. d.MaxAID(context.TODO())
  44. })
  45. }