mysql_image_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package dao
  2. import (
  3. "testing"
  4. "go-common/app/admin/ep/merlin/model"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. var (
  8. imageAdd = model.Image{
  9. Name: "docker-reg.bilibili.co/zccdebian:1.0",
  10. Status: 1,
  11. OS: "debian",
  12. Version: "1.0 64位",
  13. Description: "base",
  14. CreatedBy: "ut",
  15. }
  16. imageUpdate = model.Image{
  17. Name: "docker-reg.bilibili.co/zccdebian:1.0update",
  18. Status: 2,
  19. OS: "debian update",
  20. Version: "1.0 64位 update",
  21. Description: "base update",
  22. CreatedBy: "ut update",
  23. UpdatedBy: "ut",
  24. }
  25. )
  26. func Test_Image(t *testing.T) {
  27. Convey("add image", t, func() {
  28. err := d.AddImage(&imageAdd)
  29. So(err, ShouldBeNil)
  30. })
  31. Convey("get image", t, func() {
  32. images, err := d.Images()
  33. So(err, ShouldBeNil)
  34. So(len(images), ShouldBeGreaterThan, 0)
  35. })
  36. Convey("update image", t, func() {
  37. imageUpdate.ID = imageAdd.ID
  38. err := d.UpdateImage(&imageUpdate)
  39. So(err, ShouldBeNil)
  40. })
  41. Convey("delete image", t, func() {
  42. imageDel := model.Image{ID: imageAdd.ID}
  43. err := d.DelImage(imageDel.ID)
  44. So(err, ShouldBeNil)
  45. })
  46. }