open-vault/physical/raft/bolt_64bit_test.go
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

46 lines
848 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build !386 && !arm
package raft
import (
"os"
"strconv"
"testing"
)
func Test_BoltOptions(t *testing.T) {
t.Parallel()
key := "VAULT_RAFT_INITIAL_MMAP_SIZE"
testCases := []struct {
name string
env string
expectedSize int
}{
{"none", "", 100 * 1024 * 1024 * 1024},
{"5MB", strconv.Itoa(5 * 1024 * 1024), 5 * 1024 * 1024},
{"negative", "-1", 0},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if tc.env != "" {
current := os.Getenv(key)
defer os.Setenv(key, current)
os.Setenv(key, tc.env)
}
o := boltOptions("")
if o.InitialMmapSize != tc.expectedSize {
t.Errorf("expected InitialMmapSize to be %d but it was %d", tc.expectedSize, o.InitialMmapSize)
}
})
}
}