Skip to content

Commit

Permalink
Added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemassa committed Jan 20, 2025
1 parent 67638cc commit 6538d33
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions server/core/config/valid/repo_cfg_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package valid_test

import (
"regexp"
"testing"

validation "github.com/go-ozzo/ozzo-validation"
Expand Down Expand Up @@ -325,3 +326,54 @@ func TestConfig_AutoDiscoverEnabled(t *testing.T) {
})
}
}

func TestConfig_IsPathIgnoredForAutoDiscover(t *testing.T) {
cases := []struct {
description string
repoCfg valid.RepoCfg
path string
expIgnored bool
}{
{
description: "auto discover unconfigured",
repoCfg: valid.RepoCfg{},
path: "foo",
expIgnored: false,
},
{
description: "auto discover configured, but not path",
repoCfg: valid.RepoCfg{
AutoDiscover: &valid.AutoDiscover{},
},
path: "foo",
expIgnored: false,
},
{
description: "path does not match regex",
repoCfg: valid.RepoCfg{
AutoDiscover: &valid.AutoDiscover{
Ignore: regexp.MustCompile("bar"),
},
},
path: "foo",
expIgnored: false,
},
{
description: "path does match regex",
repoCfg: valid.RepoCfg{
AutoDiscover: &valid.AutoDiscover{
Ignore: regexp.MustCompile("fo.*"),
},
},
path: "foo",
expIgnored: true,
},
}
for _, c := range cases {
t.Run(c.description, func(t *testing.T) {

enabled := c.repoCfg.IsPathIgnoredForAutoDiscover(c.path)
Equals(t, c.expIgnored, enabled)
})
}
}

0 comments on commit 6538d33

Please sign in to comment.