github.com/blend/go-sdk@v1.20220411.3/vault/doc.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  /*
     9  Package vault implements a high throughput vault client.
    10  
    11  It also provides helpers for reading and writing objects to vault key value stores.
    12  
    13  Mock and Testing Examples
    14  
    15  Very often you will need to mock the vault client in your code so you don't reach out to and actual vault instance during tests.
    16  Before writing tests, however, you should make sure that any references to the vault client do so through the `vault.Client` interface, not a concrete type like `*vault.APIClient`.
    17  
    18  Then, in your tests, you can create a new mock:
    19  
    20  	type clientMock struct {
    21  		vault.Client // embed the vault client interface to satisfy the interface requirements.
    22  	}
    23  	// implement a specific method you need to mock
    24  	func (clientMock) Get(_ context.Context, path string, opts ...vault.CallOption) (vault.Values, error) {
    25  		return vault.Values{ "foo": "bar"}, nil
    26  	}
    27  
    28  This will then let you pass `new(clientMock)` to anywhere you need to set a `vault.Client`
    29  */
    30  package vault // import "github.com/blend/go-sdk/vault"