github.com/hashicorp/vault/sdk@v0.11.0/helper/pluginutil/env_test.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package pluginutil
     5  
     6  import (
     7  	"os"
     8  	"testing"
     9  )
    10  
    11  func TestGRPCSupport(t *testing.T) {
    12  	cases := []struct {
    13  		envVersion string
    14  		expected   bool
    15  	}{
    16  		{
    17  			"0.8.3",
    18  			false,
    19  		},
    20  		{
    21  			"0.9.2",
    22  			false,
    23  		},
    24  		{
    25  			"0.9.3",
    26  			false,
    27  		},
    28  		{
    29  			"0.9.4+ent",
    30  			true,
    31  		},
    32  		{
    33  			"0.9.4-beta",
    34  			false,
    35  		},
    36  		{
    37  			"0.9.4",
    38  			true,
    39  		},
    40  		{
    41  			"unknown",
    42  			true,
    43  		},
    44  		{
    45  			"",
    46  			false,
    47  		},
    48  	}
    49  
    50  	for _, tc := range cases {
    51  		t.Run(tc.envVersion, func(t *testing.T) {
    52  			err := os.Setenv(PluginVaultVersionEnv, tc.envVersion)
    53  			if err != nil {
    54  				t.Fatal(err)
    55  			}
    56  
    57  			result := GRPCSupport()
    58  
    59  			if result != tc.expected {
    60  				t.Fatalf("got: %t, expected: %t", result, tc.expected)
    61  			}
    62  		})
    63  	}
    64  }