aboutsummaryrefslogtreecommitdiff
path: root/internal/config/settings_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/settings_test.go')
-rw-r--r--internal/config/settings_test.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/internal/config/settings_test.go b/internal/config/settings_test.go
index e46c880..341c0f3 100644
--- a/internal/config/settings_test.go
+++ b/internal/config/settings_test.go
@@ -4,6 +4,7 @@ package config
import (
"reflect"
+ "strings"
"testing"
"time"
@@ -27,12 +28,12 @@ func parseSettings(t *testing.T, src string) (Settings, []*Diag) {
func TestSettingsResolve(t *testing.T) {
s, errs := parseSettings(t, `(case strict) (fold no) (recursive yes) (max-depth 3)
- (min-age 5m) (max-read 1G) (busy ".tmp") (on-conflict skip)`)
+ (min-age 5m) (max-read 1G) (max-size 2G) (busy ".tmp") (on-conflict skip)`)
if len(errs) > 0 {
t.Fatal(errs)
}
want := Resolved{Case: CaseStrict, Fold: false, Recursive: true, MaxDepth: 3,
- MinAge: 5 * time.Minute, MaxRead: 1 << 30, Busy: []string{".tmp"}, OnConflict: ConflictSkip}
+ MinAge: 5 * time.Minute, MaxRead: 1 << 30, MaxSize: 2 << 30, Busy: []string{".tmp"}, OnConflict: ConflictSkip}
if got := s.Over(Builtin()); !reflect.DeepEqual(got, want) {
t.Fatalf("got %+v\nwant %+v", got, want)
}
@@ -83,3 +84,14 @@ func TestSettingErrors(t *testing.T) {
}
}
}
+
+// TestMaxSizeErrors: max-size takes a size like max-read does, and is not a
+// rule-level setting.
+func TestMaxSizeErrors(t *testing.T) {
+ if _, errs := parseSettings(t, "(max-size big)"); len(errs) != 1 || !strings.Contains(errs[0].Msg, "max-size") {
+ t.Errorf("(max-size big): errs %v, want one max-size error", errs)
+ }
+ if _, errs := parseSettings(t, "(max-size 10M)"); len(errs) != 0 {
+ t.Errorf("(max-size 10M): errs %v, want none", errs)
+ }
+}