github.com/hashicorp/vault/sdk@v0.13.0/plugin/storage_test.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package plugin
     5  
     6  import (
     7  	"context"
     8  	"testing"
     9  
    10  	"github.com/hashicorp/go-plugin"
    11  	"github.com/hashicorp/vault/sdk/logical"
    12  	"github.com/hashicorp/vault/sdk/plugin/pb"
    13  	"google.golang.org/grpc"
    14  )
    15  
    16  func TestStorage_GRPC_ReturnsErrIfStorageNil(t *testing.T) {
    17  	_, err := new(GRPCStorageServer).Get(context.Background(), nil)
    18  	if err == nil {
    19  		t.Error("Expected error when using server with no impl")
    20  	}
    21  }
    22  
    23  func TestStorage_impl(t *testing.T) {
    24  	var _ logical.Storage = new(GRPCStorageClient)
    25  }
    26  
    27  func TestStorage_GRPC(t *testing.T) {
    28  	storage := &logical.InmemStorage{}
    29  	client, _ := plugin.TestGRPCConn(t, func(s *grpc.Server) {
    30  		pb.RegisterStorageServer(s, &GRPCStorageServer{
    31  			impl: storage,
    32  		})
    33  	})
    34  	defer client.Close()
    35  
    36  	testStorage := &GRPCStorageClient{client: pb.NewStorageClient(client)}
    37  
    38  	logical.TestStorage(t, testStorage)
    39  }