mirror of
https://github.com/fleetdm/fleet
synced 2026-05-16 13:38:43 +00:00
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
29 lines
545 B
Go
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())
|
|
}
|
|
}
|