label_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package service
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. "go-common/app/admin/ep/melloi/model"
  6. )
  7. var (
  8. label = model.Label{
  9. ID: 1,
  10. Name: "name",
  11. Description: "description",
  12. Color: "#602230",
  13. Active: 1,
  14. }
  15. lr = model.LabelRelation{
  16. ID: 1,
  17. LabelID: 1,
  18. LabelName: "name",
  19. Color: "#602230",
  20. Description: "description",
  21. TargetID: 1,
  22. Type: 1,
  23. Active: 1,
  24. }
  25. ids = []int64{1, 2, 3, 4, 5}
  26. )
  27. func Test_Label(t *testing.T) {
  28. Convey("add label", t, func() {
  29. err := s.AddLabel(&label)
  30. So(err, ShouldBeNil)
  31. })
  32. Convey("query label", t, func() {
  33. _, err := s.QueryLabel(c)
  34. So(err, ShouldBeNil)
  35. })
  36. Convey("delete label", t, func() {
  37. err := s.DeleteLabel(label.ID)
  38. So(err, ShouldBeNil)
  39. })
  40. Convey("delete label relation", t, func() {
  41. err := s.AddLabelRelation(&lr)
  42. So(err, ShouldBeNil)
  43. })
  44. Convey("delete label relation", t, func() {
  45. err := s.DeleteLabelRelation(lr.ID)
  46. So(err, ShouldBeNil)
  47. })
  48. Convey("query label relation", t, func() {
  49. _, err := s.QueryLabelRelation(&lr)
  50. So(err, ShouldBeNil)
  51. })
  52. Convey("query label relation by ids", t, func() {
  53. _, err := s.QueryLabelRelationByIDs(ids)
  54. So(err, ShouldBeNil)
  55. })
  56. }