mysql_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/app/job/main/answer/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestAddQue(t *testing.T) {
  10. Convey("TestAddQue add question data", t, func() {
  11. for i := 0; i < 10; i++ {
  12. que := &model.LabourQs{
  13. Question: fmt.Sprintf("测试d=====( ̄▽ ̄*)b厉害 %d", i),
  14. Ans: int8(i%2 + 1),
  15. AvID: int64(i),
  16. Status: int8(i%2 + 1),
  17. Source: 1,
  18. State: model.HadCreateImg,
  19. ID: int64(i),
  20. }
  21. err := d.AddQs(context.TODO(), que)
  22. So(err, ShouldBeNil)
  23. }
  24. })
  25. }
  26. func TestUpdateState(t *testing.T) {
  27. Convey("TestUpdateState", t, func() {
  28. for i := 0; i < 10; i++ {
  29. que := &model.LabourQs{
  30. Question: fmt.Sprintf("测试d=====( ̄▽ ̄*)b厉害 %d", i),
  31. Ans: int8(i%2 + 1),
  32. AvID: int64(i),
  33. Status: int8(i%2 + 1),
  34. Source: 1,
  35. State: model.HadCreateImg,
  36. ID: int64(i),
  37. }
  38. err := d.UpdateState(context.TODO(), que)
  39. So(err, ShouldBeNil)
  40. }
  41. })
  42. }
  43. func TestByID(t *testing.T) {
  44. Convey("TestByID", t, func() {
  45. res, err := d.ByID(context.TODO(), 1)
  46. So(err, ShouldBeNil)
  47. So(res, ShouldNotBeNil)
  48. })
  49. }
  50. func TestBeFormal(t *testing.T) {
  51. Convey("TestBeFormal", t, func() {
  52. err := d.BeFormal(context.TODO(), 7593623, "127.0.0.1")
  53. So(err, ShouldNotBeNil)
  54. })
  55. }