semverutil_test.go 970 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package semverutil
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestCheck(t *testing.T) {
  10. tests := []struct {
  11. version1 string
  12. comparison string
  13. version2 string
  14. expVal bool
  15. }{
  16. {version1: "1.0.c", comparison: ">", version2: "0.9", expVal: false},
  17. {version1: "1.0.1", comparison: ">", version2: "0.9.a", expVal: false},
  18. {version1: "7.2", comparison: ">=", version2: "5.1", expVal: true},
  19. {version1: "1.8.3.1", comparison: ">=", version2: "1.8.3", expVal: true},
  20. {version1: "0.12.0+dev", comparison: ">=", version2: "0.11.68.1023", expVal: true},
  21. }
  22. for _, test := range tests {
  23. t.Run(test.version1+" "+test.comparison+" "+test.version2, func(t *testing.T) {
  24. assert.Equal(t, test.expVal, Compare(test.version1, test.comparison, test.version2))
  25. })
  26. }
  27. }