upgrade_all_command_test.go 958 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package commands
  2. import (
  3. "testing"
  4. m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestVersionComparsion(t *testing.T) {
  8. Convey("Validate that version is outdated", t, func() {
  9. versions := []m.Version{
  10. {Version: "1.1.1"},
  11. {Version: "2.0.0"},
  12. }
  13. shouldUpgrade := map[string]m.Plugin{
  14. "0.0.0": {Versions: versions},
  15. "1.0.0": {Versions: versions},
  16. }
  17. Convey("should return error", func() {
  18. for k, v := range shouldUpgrade {
  19. So(ShouldUpgrade(k, v), ShouldBeTrue)
  20. }
  21. })
  22. })
  23. Convey("Validate that version is ok", t, func() {
  24. versions := []m.Version{
  25. {Version: "1.1.1"},
  26. {Version: "2.0.0"},
  27. }
  28. shouldNotUpgrade := map[string]m.Plugin{
  29. "2.0.0": {Versions: versions},
  30. "6.0.0": {Versions: versions},
  31. }
  32. Convey("should return error", func() {
  33. for k, v := range shouldNotUpgrade {
  34. So(ShouldUpgrade(k, v), ShouldBeFalse)
  35. }
  36. })
  37. })
  38. }