github.com/blend/go-sdk@v1.20220411.3/vault/tracer_test.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  package vault
     9  
    10  import (
    11  	"testing"
    12  
    13  	"github.com/blend/go-sdk/assert"
    14  )
    15  
    16  func TestOptTraceConfig(t *testing.T) {
    17  	a := assert.New(t)
    18  	var empty SecretTraceConfig
    19  	config := SecretTraceConfig{
    20  		KeyName:        "A_KEY",
    21  		VaultOperation: "k1.put",
    22  	}
    23  
    24  	err := OptTraceConfig(config)(&empty)
    25  	a.Nil(err)
    26  	a.Equal("A_KEY", empty.KeyName)
    27  	a.Equal("k1.put", empty.VaultOperation)
    28  }
    29  
    30  func TestOptTraceKeyName(t *testing.T) {
    31  	a := assert.New(t)
    32  	var ptr *SecretTraceConfig
    33  
    34  	err := OptTraceKeyName("A_KEY")(ptr)
    35  	a.NotNil(err)
    36  
    37  	ptr = &SecretTraceConfig{}
    38  
    39  	err = OptTraceKeyName("A_KEY")(ptr)
    40  	a.Nil(err)
    41  	a.Equal("A_KEY", ptr.KeyName)
    42  }
    43  
    44  func TestOptTraceVaultOperation(t *testing.T) {
    45  	a := assert.New(t)
    46  	var ptr *SecretTraceConfig
    47  
    48  	err := OptTraceVaultOperation("k1.put")(ptr)
    49  	a.NotNil(err)
    50  
    51  	ptr = &SecretTraceConfig{}
    52  
    53  	err = OptTraceVaultOperation("k1.put")(ptr)
    54  	a.Nil(err)
    55  	a.Equal("k1.put", ptr.VaultOperation)
    56  }