mysql_test.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/app/admin/main/spy/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. var (
  10. statID int64 = 3
  11. statState int8 = 1
  12. statCount int64 = 1
  13. statIsdel int8 = 1
  14. statMid int64 = 1
  15. statType int8 = 2
  16. pn = 1
  17. ps = 8
  18. )
  19. // go test -test.v -test.run TestDB
  20. func TestDB(t *testing.T) {
  21. Convey(" UpdateStatState ", t, WithMysql(func(d *Dao) {
  22. _, err := d.UpdateStatState(context.TODO(), statState, statID)
  23. So(err, ShouldBeNil)
  24. }))
  25. Convey(" UpdateStatQuantity ", t, WithMysql(func(d *Dao) {
  26. _, err := d.UpdateStatQuantity(context.TODO(), statCount, statID)
  27. So(err, ShouldBeNil)
  28. }))
  29. Convey(" DeleteStat ", t, WithMysql(func(d *Dao) {
  30. _, err := d.DeleteStat(context.TODO(), statIsdel, statID)
  31. So(err, ShouldBeNil)
  32. }))
  33. Convey(" Statistics ", t, WithMysql(func(d *Dao) {
  34. stat, err := d.Statistics(context.TODO(), statID)
  35. So(err, ShouldBeNil)
  36. fmt.Println("stat", stat)
  37. }))
  38. Convey(" LogList ", t, WithMysql(func(d *Dao) {
  39. logs, err := d.LogList(context.TODO(), statID, model.UpdateStat)
  40. So(err, ShouldBeNil)
  41. for _, l := range logs {
  42. fmt.Println(l.Context)
  43. }
  44. }))
  45. Convey(" StatListByMid ", t, WithMysql(func(d *Dao) {
  46. stat, err := d.StatListByMid(context.TODO(), statMid, pn, ps)
  47. So(err, ShouldBeNil)
  48. for _, s := range stat {
  49. fmt.Println(s.EventID)
  50. }
  51. }))
  52. Convey(" StatListByID ", t, WithMysql(func(d *Dao) {
  53. stat, err := d.StatListByID(context.TODO(), statID, statType, pn, ps)
  54. So(err, ShouldBeNil)
  55. for _, s := range stat {
  56. fmt.Println(s.EventID)
  57. }
  58. }))
  59. Convey(" StatCountByMid ", t, WithMysql(func(d *Dao) {
  60. stat, err := d.StatCountByMid(context.TODO(), statMid)
  61. So(err, ShouldBeNil)
  62. fmt.Println("count ", stat)
  63. }))
  64. Convey(" StatCountByID ", t, WithMysql(func(d *Dao) {
  65. stat, err := d.StatCountByID(context.TODO(), statID, statType)
  66. So(err, ShouldBeNil)
  67. fmt.Println("count ", stat)
  68. }))
  69. }