open-vault/sdk/helper/pluginutil/env_test.go
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

65 lines
778 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package pluginutil
import (
"os"
"testing"
)
func TestGRPCSupport(t *testing.T) {
cases := []struct {
envVersion string
expected bool
}{
{
"0.8.3",
false,
},
{
"0.9.2",
false,
},
{
"0.9.3",
false,
},
{
"0.9.4+ent",
true,
},
{
"0.9.4-beta",
false,
},
{
"0.9.4",
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)
}
})
}
}