build_test.go 1013 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (C) 2019 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package build
  7. import (
  8. "testing"
  9. )
  10. func TestAllowedVersions(t *testing.T) {
  11. testcases := []struct {
  12. ver string
  13. allowed bool
  14. }{
  15. {"v0.13.0", true},
  16. {"v0.12.11+22-gabcdef0", true},
  17. {"v0.13.0-beta0", true},
  18. {"v0.13.0-beta47", true},
  19. {"v0.13.0-beta47+1-gabcdef0", true},
  20. {"v0.13.0-beta.0", true},
  21. {"v0.13.0-beta.47", true},
  22. {"v0.13.0-beta.0+1-gabcdef0", true},
  23. {"v0.13.0-beta.47+1-gabcdef0", true},
  24. {"v0.13.0-some-weird-but-allowed-tag", true},
  25. {"v0.13.0-allowed.to.do.this", true},
  26. {"v0.13.0+not.allowed.to.do.this", false},
  27. }
  28. for i, c := range testcases {
  29. if allowed := allowedVersionExp.MatchString(c.ver); allowed != c.allowed {
  30. t.Errorf("%d: incorrect result %v != %v for %q", i, allowed, c.allowed, c.ver)
  31. }
  32. }
  33. }