aboutsummaryrefslogtreecommitdiff
path: root/internal/config/main_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/main_test.go')
-rw-r--r--internal/config/main_test.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/internal/config/main_test.go b/internal/config/main_test.go
index a82dfcd..be39faf 100644
--- a/internal/config/main_test.go
+++ b/internal/config/main_test.go
@@ -4,6 +4,7 @@ package config
import (
"reflect"
+ "strings"
"testing"
"time"
)
@@ -54,7 +55,7 @@ func TestParseMainErrors(t *testing.T) {
{`(log "rel/x")`, `k:1:6: log path must be absolute or start with ~`},
{`(defaults (recursive maybe))`, `k:1:22: recursive is yes or no, not maybe`},
{`(defaults (rule "x"))`, `k:1:11: defaults holds settings like (min-age 2m); got (rule "x")`},
- {`(inlcude "a")`, `k:1:1: unknown form (inlcude ...); krino.conf has include, log and defaults`},
+ {`(inlcude "a")`, `k:1:1: unknown form (inlcude ...); krino.conf has include, log, defaults and exclude`},
{`include`, `k:1:1: expected a form like (include ...), got include`},
{`(include "a"`, `k:1:1: "(" never closed: (include "a")`},
}
@@ -65,3 +66,18 @@ func TestParseMainErrors(t *testing.T) {
}
}
}
+
+// TestParseMainExclude: krino.conf may hold (exclude ...) forms, which
+// apply to every directory.
+func TestParseMainExclude(t *testing.T) {
+ m, errs := ParseMain("krino.conf", []byte("(include \"a\")\n(exclude (type iso))\n(exclude (name \"[.]asc$\"))\n"))
+ if len(errs) != 0 {
+ t.Fatal(errs)
+ }
+ if len(m.Excludes) != 2 || m.Excludes[0].Text != "(exclude (type iso))" {
+ t.Fatalf("Excludes = %+v", m.Excludes)
+ }
+ if _, errs := ParseMain("krino.conf", []byte("(exclude)")); len(errs) != 1 || !strings.Contains(errs[0].Msg, "(exclude) needs a condition") {
+ t.Errorf("(exclude): errs %v", errs)
+ }
+}