Files
sqlite3/litestream/vfs_test.go

35 lines
931 B
Go
Raw Normal View History

2025-11-19 16:22:10 +00:00
package litestream
import (
2025-11-19 16:22:10 +00:00
"slices"
"strconv"
"testing"
2025-11-19 16:22:10 +00:00
"github.com/benbjohnson/litestream"
2025-11-20 11:35:01 +00:00
_ "github.com/ncruces/go-sqlite3/embed"
)
2025-11-19 16:22:10 +00:00
func Test_pollLevels(t *testing.T) {
tests := []struct {
minLevel int
want []int
}{
{minLevel: -1, want: []int{0, 1, litestream.SnapshotLevel}},
{minLevel: 0, want: []int{0, 1, litestream.SnapshotLevel}},
{minLevel: 1, want: []int{1, litestream.SnapshotLevel}},
{minLevel: 2, want: []int{2, litestream.SnapshotLevel}},
{minLevel: 3, want: []int{3, litestream.SnapshotLevel}},
{minLevel: litestream.SnapshotLevel, want: []int{litestream.SnapshotLevel}},
{minLevel: litestream.SnapshotLevel + 1, want: []int{litestream.SnapshotLevel}},
}
2025-11-19 16:22:10 +00:00
for _, tt := range tests {
t.Run(strconv.Itoa(tt.minLevel), func(t *testing.T) {
got := pollLevels(tt.minLevel)
if !slices.Equal(got, tt.want) {
t.Errorf("pollLevels() = %v, want %v", got, tt.want)
}
2025-11-19 16:22:10 +00:00
})
}
}