vault/helper/pluginutil/version_test.go
Calvin Leung Huang c3c63313f3
Version protocol switch (#3833)
* Use version to determine plugin protocol to use

* Remove field from ServeOpts

* Fix missing assignment, handle errors

* contraint -> constraint

* Inject the version string from the vault side

* Fix the version check

* Add grpc support check to database plugins

* Default to use grpc unless missing env var or fail on contraint check

* Add GRPCSupport test

* Add greater than test case

* Add go-version dep
2018-01-23 17:29:26 -05:00

58 lines
676 B
Go

package pluginutil
import (
"os"
"testing"
)
func TestGRPCSupport(t *testing.T) {
cases := []struct {
envVersion string
expected bool
}{
{
"0.8.3",
false,
},
{
"0.9.2",
true,
},
{
"0.9.2+ent",
true,
},
{
"0.9.2-beta",
false,
},
{
"0.9.3",
true,
},
{
"unknown",
true,
},
{
"",
false,
},
}
for _, tc := range cases {
t.Run(tc.envVersion, func(t *testing.T) {
err := os.Setenv(PluginVaultVersionEnv, tc.envVersion)
if err != nil {
t.Fatal(err)
}
result := GRPCSupport()
if result != tc.expected {
t.Fatalf("got: %t, expected: %t", result, tc.expected)
}
})
}
}