Files
kopia/internal/stat/stat_test.go
Nathan Baulch 657fda216a chore(ci): upgrade to golangci-lint 2.6.1 (#4973)
- upgrade to golangci-lint 2.6.1
- updates for gosec
- updates for govet
- updates for perfsprint
- updates modernize

Leaves out modernize:omitempty due to conflicts with tests
2025-11-11 21:27:10 -08:00

42 lines
876 B
Go

//go:build !windows
package stat
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
func TestGetBlockSize(t *testing.T) {
size, err := GetBlockSize(os.DevNull)
require.NoError(t, err)
require.Positive(t, size)
}
func TestGetBlockSizeFromCurrentFS(t *testing.T) {
size, err := GetBlockSize(".")
require.NoError(t, err)
require.Positive(t, size)
}
func TestGetFileAllocSize(t *testing.T) {
const expectedMinAllocSize = 512
d := t.TempDir()
f := filepath.Join(d, "test")
err := os.WriteFile(f, []byte{1}, os.ModePerm)
require.NoError(t, err)
s, err := GetFileAllocSize(f)
require.NoError(t, err, "error getting file alloc size for %s: %v", f, err)
t.Log("file alloc size:", s)
require.GreaterOrEqual(t, s, uint64(expectedMinAllocSize), "invalid allocated file size %d, expected at least %d", s, expectedMinAllocSize)
}