github.com/hashicorp/vault/sdk@v0.13.0/physical/encoding_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/stretchr/testify/require" 10 ) 11 12 func TestTransactionalStorageEncoding_TransactionLimits(t *testing.T) { 13 tc := []struct { 14 name string 15 be Backend 16 wantEntries int 17 wantSize int 18 }{ 19 { 20 name: "non-transactionlimits backend", 21 be: &TestTransactionalNonLimitBackend{}, 22 23 // Should return zeros to let the implementor choose defaults. 24 wantEntries: 0, 25 wantSize: 0, 26 }, 27 { 28 name: "transactionlimits backend", 29 be: &TestTransactionalLimitBackend{ 30 MaxEntries: 123, 31 MaxSize: 345, 32 }, 33 34 // Should return underlying limits 35 wantEntries: 123, 36 wantSize: 345, 37 }, 38 } 39 40 for _, tt := range tc { 41 t.Run(tt.name, func(t *testing.T) { 42 be := NewStorageEncoding(tt.be).(TransactionalLimits) 43 44 // Call the TransactionLimits method 45 maxEntries, maxBytes := be.TransactionLimits() 46 47 require.Equal(t, tt.wantEntries, maxEntries) 48 require.Equal(t, tt.wantSize, maxBytes) 49 }) 50 } 51 }