2018-01-23 22:29:26 +00:00
|
|
|
package pluginutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGRPCSupport(t *testing.T) {
|
|
|
|
cases := []struct {
|
|
|
|
envVersion string
|
|
|
|
expected bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"0.8.3",
|
|
|
|
false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"0.9.2",
|
2018-02-01 22:30:17 +00:00
|
|
|
false,
|
2018-01-23 22:29:26 +00:00
|
|
|
},
|
|
|
|
{
|
2018-02-01 22:30:17 +00:00
|
|
|
"0.9.3",
|
|
|
|
false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"0.9.4+ent",
|
2018-01-23 22:29:26 +00:00
|
|
|
true,
|
|
|
|
},
|
|
|
|
{
|
2018-02-01 22:30:17 +00:00
|
|
|
"0.9.4-beta",
|
2018-01-23 22:29:26 +00:00
|
|
|
false,
|
|
|
|
},
|
|
|
|
{
|
2018-02-01 22:30:17 +00:00
|
|
|
"0.9.4",
|
2018-01-23 22:29:26 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|