diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 14:08:36 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 14:08:36 +0200 |
| commit | 1d3f2d1e4c59867024470d3444e12698b7ebb22e (patch) | |
| tree | 4fa14f455c72f9b206a680dcc1b0f4c1f3708158 /internal/config/main_test.go | |
| parent | 07c24054cab965800983ef40f53a05c2db131ede (diff) | |
| download | krino-0.0.4.tar.gz krino-0.0.4.zip | |
0.0.4: max-size, exclude forms, --min-agev0.0.4
Diffstat (limited to 'internal/config/main_test.go')
| -rw-r--r-- | internal/config/main_test.go | 18 |
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) + } +} |
