mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 21:35:52 +00:00
b8b37c2357
Ensure nothing in the troubleshoot go module depends on consul's top level module. This is so we can import troubleshoot into consul-k8s and not import all of consul. * turns troubleshoot into a go module [authored by @curtbushko] * gets the envoy protos into the troubleshoot module [authored by @curtbushko] * adds a new go module `envoyextensions` which has xdscommon and extensioncommon folders that both the xds package and the troubleshoot package can import * adds testing and linting for the new go modules * moves the unit tests in `troubleshoot/validateupstream` that depend on proxycfg/xds into the xds package, with a comment describing why those tests cannot be in the troubleshoot package * fixes all the imports everywhere as a result of these changes Co-authored-by: Curt Bushko <cbushko@gmail.com>
31 lines
765 B
Go
31 lines
765 B
Go
package xdscommon
|
|
|
|
import (
|
|
"sort"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/go-version"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestProxySupportOrder(t *testing.T) {
|
|
versions := make([]*version.Version, len(EnvoyVersions))
|
|
beforeSort := make([]*version.Version, len(EnvoyVersions))
|
|
for i, raw := range EnvoyVersions {
|
|
v, _ := version.NewVersion(raw)
|
|
versions[i] = v
|
|
beforeSort[i] = v
|
|
}
|
|
|
|
// After this, the versions are properly sorted
|
|
// go-version has a collection container, but it only allows for sorting in ascending order
|
|
sort.Slice(versions, func(i, j int) bool {
|
|
return versions[j].LessThan(versions[i])
|
|
})
|
|
|
|
// Check that we already have a sorted list
|
|
for i := range EnvoyVersions {
|
|
assert.True(t, versions[i].Equal(beforeSort[i]))
|
|
}
|
|
}
|