github.com/hashicorp/vault/sdk@v0.13.0/physical/error_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package physical 5 6 import ( 7 "testing" 8 9 "github.com/hashicorp/go-hclog" 10 "github.com/stretchr/testify/require" 11 ) 12 13 func TestTransactionalErrorInjector_TransactionLimits(t *testing.T) { 14 tc := []struct { 15 name string 16 be Backend 17 wantEntries int 18 wantSize int 19 }{ 20 { 21 name: "non-transactionlimits backend", 22 be: &TestTransactionalNonLimitBackend{}, 23 24 // Should return zeros to let the implementor choose defaults. 25 wantEntries: 0, 26 wantSize: 0, 27 }, 28 { 29 name: "transactionlimits backend", 30 be: &TestTransactionalLimitBackend{ 31 MaxEntries: 123, 32 MaxSize: 345, 33 }, 34 35 // Should return underlying limits 36 wantEntries: 123, 37 wantSize: 345, 38 }, 39 } 40 41 for _, tt := range tc { 42 t.Run(tt.name, func(t *testing.T) { 43 logger := hclog.NewNullLogger() 44 45 injector := NewTransactionalErrorInjector(tt.be, 0, logger) 46 47 maxEntries, maxBytes := injector.TransactionLimits() 48 49 require.Equal(t, tt.wantEntries, maxEntries) 50 require.Equal(t, tt.wantSize, maxBytes) 51 }) 52 } 53 }