fleet/server/fleet/utils_test.go
Konstantin Sykulev d8930250f8
Added util func around semver to allow for custom preprocessing. Upgraded semver lib (#25437)
For https://github.com/fleetdm/fleet/issues/22919

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files)
for more information.
- [x] Added/updated automated tests
- [ ] A detailed QA plan exists on the associated ticket (if it isn't
there, work with the product group's QA engineer to add it)
- [ ] Manual QA for all new/changed functionality
2025-01-23 10:21:15 -06:00

29 lines
545 B
Go

package fleet
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestVersionToSemvarVersion(t *testing.T) {
tests := []struct {
version string
want string
}{
{"1", "1.0.0"},
{"1.0", "1.0.0"},
{"0.0.4", "0.0.4"},
{"1.0.0", "1.0.0"},
{"12.0.9", "12.0.9"},
{"1.0.0-alpha", "1.0.0-alpha"},
{"1.1.2+meta", "1.1.2+meta"},
{"13.3.1 (a)", "13.3.1"},
}
for _, tt := range tests {
result, err := VersionToSemverVersion(tt.version)
require.NoError(t, err)
require.Equal(t, tt.want, result.String())
}
}