semverutil_test.go 808 B

12345678910111213141516171819202122232425262728
  1. package semverutil
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestCheck(t *testing.T) {
  7. tests := []struct {
  8. version1 string
  9. comparison string
  10. version2 string
  11. expVal bool
  12. }{
  13. {version1: "1.0.c", comparison: ">", version2: "0.9", expVal: false},
  14. {version1: "1.0.1", comparison: ">", version2: "0.9.a", expVal: false},
  15. {version1: "7.2", comparison: ">=", version2: "5.1", expVal: true},
  16. {version1: "1.8.3.1", comparison: ">=", version2: "1.8.3", expVal: true},
  17. {version1: "0.12.0+dev", comparison: ">=", version2: "0.11.68.1023", expVal: true},
  18. }
  19. for _, test := range tests {
  20. t.Run(test.version1+" "+test.comparison+" "+test.version2, func(t *testing.T) {
  21. assert.Equal(t, test.expVal, Compare(test.version1, test.comparison, test.version2))
  22. })
  23. }
  24. }