cal_diff_test.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package caldiff
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "testing"
  6. "go-common/app/job/main/appstatic/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. const (
  10. _availableRes = "SELECT id FROM resource ORDER BY id DESC"
  11. )
  12. func TestDao_DiffNew(t *testing.T) {
  13. Convey("TestDao_DiffNew", t, WithDao(func(d *Dao) {
  14. file, err := d.DiffNew(ctx)
  15. So(err, ShouldBeNil)
  16. data, err2 := (json.Marshal(file))
  17. So(err2, ShouldBeNil)
  18. fmt.Println(string(data))
  19. }))
  20. }
  21. func TestDao_DiffRetry(t *testing.T) {
  22. Convey("TestDao_DiffRetry", t, WithDao(func(d *Dao) {
  23. file, err := d.DiffRetry(ctx)
  24. So(err, ShouldBeNil)
  25. data, err2 := (json.Marshal(file))
  26. So(err2, ShouldBeNil)
  27. fmt.Println(string(data))
  28. }))
  29. }
  30. func TestDao_SaveFile(t *testing.T) {
  31. Convey("TestDao_SaveFile", t, WithDao(func(d *Dao) {
  32. err := d.SaveFile(ctx, 1, &model.FileInfo{
  33. Name: "123",
  34. Size: 123,
  35. Type: "1",
  36. Md5: "1234",
  37. URL: "xxx",
  38. })
  39. So(err, ShouldBeNil)
  40. }))
  41. }
  42. func TestDao_ParseResID(t *testing.T) {
  43. Convey("TestDao_ParseResID", t, WithDao(func(d *Dao) {
  44. var r = &model.Resource{}
  45. if err := d.db.QueryRow(ctx, _availableRes).Scan(&r.ID); err != nil {
  46. return
  47. }
  48. res, err := d.ParseResID(ctx, int(r.ID))
  49. So(err, ShouldBeNil)
  50. So(res, ShouldNotBeNil)
  51. fmt.Println(r.ID)
  52. }))
  53. }
  54. func TestDao_ParseResVer(t *testing.T) {
  55. Convey("TestDao_ParseResVer", t, WithDao(func(d *Dao) {
  56. dd, err := d.ParseResVer(ctx, 23, 1)
  57. So(err, ShouldBeNil)
  58. fmt.Println(err)
  59. So(dd, ShouldNotBeNil)
  60. data, err2 := (json.Marshal(dd))
  61. So(err2, ShouldBeNil)
  62. fmt.Println(string(data))
  63. }))
  64. }
  65. func TestDao_ReadyFile(t *testing.T) {
  66. Convey("TestDao_ReadyFile", t, WithDao(func(d *Dao) {
  67. var r = &model.Resource{}
  68. if err := d.db.QueryRow(ctx, _availableRes).Scan(&r.ID); err != nil {
  69. return
  70. }
  71. dd, err := d.ReadyFile(ctx, int(r.ID), 0) // ftype = 0 full package
  72. So(err, ShouldBeNil)
  73. So(dd, ShouldNotBeNil)
  74. data, _ := json.Marshal(dd)
  75. fmt.Println(string(data))
  76. }))
  77. }
  78. func TestDao_UpdateStatus(t *testing.T) {
  79. Convey("TestDao_UpdateStatus", t, WithDao(func(d *Dao) {
  80. err := d.UpdateStatus(ctx, 2, 304)
  81. So(err, ShouldBeNil)
  82. }))
  83. }