mysql_bugly_issue_test.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package dao
  2. import (
  3. "strconv"
  4. "testing"
  5. "time"
  6. "go-common/app/admin/ep/marthe/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. var (
  10. tmpIssueNoStr = strconv.FormatInt(time.Now().Unix(), 10)
  11. tmpTapdBugID = "bug" + tmpIssueNoStr
  12. buglyIssue = &model.BuglyIssue{
  13. IssueNo: tmpIssueNoStr,
  14. Title: "Title" + tmpIssueNoStr,
  15. ExceptionMsg: "ExceptionMsg" + tmpIssueNoStr,
  16. KeyStack: "KeyStack" + tmpIssueNoStr,
  17. Detail: "Detail" + tmpIssueNoStr,
  18. Tags: "Tags" + tmpIssueNoStr,
  19. LastTime: time.Now(),
  20. HappenTimes: 10,
  21. UserTimes: 20,
  22. Version: "Version" + tmpIssueNoStr,
  23. ProjectID: "ProjectID" + tmpIssueNoStr,
  24. IssueLink: "IssueLink" + tmpIssueNoStr,
  25. }
  26. queryBuglyIssueRequest = &model.QueryBuglyIssueRequest{
  27. Pagination: model.Pagination{
  28. PageSize: 10,
  29. PageNum: 1,
  30. },
  31. IssueNo: buglyIssue.IssueNo,
  32. }
  33. )
  34. func Test_Bugly_Issue(t *testing.T) {
  35. Convey("test insert bugly issue", t, func() {
  36. err := d.InsertBuglyIssue(buglyIssue)
  37. So(err, ShouldBeNil)
  38. })
  39. Convey("test update Bugly Issue", t, func() {
  40. buglyIssue.ExceptionMsg = "update exception message"
  41. err := d.UpdateBuglyIssue(buglyIssue)
  42. So(err, ShouldBeNil)
  43. })
  44. Convey("test update Bugly Issue tapd bug id", t, func() {
  45. err := d.UpdateBuglyIssueTapdBugID(buglyIssue.ID, tmpTapdBugID)
  46. So(err, ShouldBeNil)
  47. })
  48. Convey("test Get Bugly Issue", t, func() {
  49. tmpBuglyIssue, err := d.GetBuglyIssue(buglyIssue.IssueNo, buglyIssue.Version)
  50. So(err, ShouldBeNil)
  51. So(tmpBuglyIssue.ID, ShouldEqual, buglyIssue.ID)
  52. })
  53. Convey("test Get Bugly Issues By Filter SQL", t, func() {
  54. sql := "select * from bugly_issues where issue_no = '" + buglyIssue.IssueNo + "'"
  55. tmpBuglyIssues, err := d.GetBuglyIssuesByFilterSQL(sql)
  56. So(err, ShouldBeNil)
  57. So(tmpBuglyIssues[0].IssueNo, ShouldEqual, buglyIssue.IssueNo)
  58. })
  59. Convey("test Find Bugly Issues", t, func() {
  60. total, tmpBuglyIssues, err := d.FindBuglyIssues(queryBuglyIssueRequest)
  61. So(err, ShouldBeNil)
  62. So(total, ShouldBeGreaterThan, 0)
  63. So(len(tmpBuglyIssues), ShouldBeGreaterThan, 0)
  64. })
  65. }