view_test.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package archive
  2. import (
  3. "context"
  4. "encoding/json"
  5. "fmt"
  6. "testing"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func Test_View3(t *testing.T) {
  10. Convey("view3", t, func() {
  11. aid, errGet := getPassAid(d.db)
  12. if errGet != nil {
  13. fmt.Println(errGet)
  14. return
  15. }
  16. vp, err := d.view3(context.Background(), aid)
  17. fmt.Println(vp, " ", aid)
  18. So(err, ShouldBeNil)
  19. So(vp, ShouldNotBeNil)
  20. })
  21. }
  22. func Test_ViewCache(t *testing.T) {
  23. Convey("viewCache", t, func() {
  24. reply, err := d.viewCache(context.TODO(), 123)
  25. So(reply, ShouldNotBeNil)
  26. So(err, ShouldBeNil)
  27. })
  28. }
  29. func TestDao_Progress(t *testing.T) {
  30. Convey("TestDao_Progress", t, func() {
  31. aid, errGet := getPassAid(d.db)
  32. if errGet != nil {
  33. fmt.Println(errGet)
  34. return
  35. }
  36. h, err := d.Progress(context.TODO(), aid, 88895137)
  37. So(err, ShouldBeNil)
  38. fmt.Println(h)
  39. })
  40. }
  41. func TestDao_LoadViews(t *testing.T) {
  42. Convey("TestDao_LoadViews", t, func() {
  43. resMetas := d.LoadViews(context.Background(), []int64{10110328, 10099960})
  44. data, _ := json.Marshal(resMetas)
  45. fmt.Println(string(data))
  46. })
  47. }
  48. func TestDao_Archives(t *testing.T) {
  49. Convey("TestDao_Archives", t, WithDao(func(d *Dao) {
  50. aid, errGet := getPassAid(d.db)
  51. if errGet != nil {
  52. fmt.Println(errGet)
  53. return
  54. }
  55. as, err := d.Archives(context.Background(), []int64{aid})
  56. So(err, ShouldBeNil)
  57. So(len(as), ShouldBeGreaterThan, 0)
  58. fmt.Println(as)
  59. }))
  60. }
  61. func TestDao_GetView(t *testing.T) {
  62. Convey("TestDao_Archives", t, WithDao(func(d *Dao) {
  63. aid, errGet := getPassAid(d.db)
  64. if errGet != nil {
  65. fmt.Println(errGet)
  66. return
  67. }
  68. vp, err := d.GetView(context.Background(), aid)
  69. So(err, ShouldBeNil)
  70. So(vp, ShouldNotBeNil)
  71. fmt.Println(vp)
  72. }))
  73. }
  74. func TestDao_Archive3(t *testing.T) {
  75. Convey("TestDao_Archives", t, WithDao(func(d *Dao) {
  76. aid, errGet := getPassAid(d.db)
  77. if errGet != nil {
  78. fmt.Println(errGet)
  79. return
  80. }
  81. vp, err := d.Archive3(context.Background(), aid)
  82. So(err, ShouldBeNil)
  83. So(vp, ShouldNotBeNil)
  84. fmt.Println(vp)
  85. }))
  86. }