mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
Patch points of test flag leakage (#667)
This commit is contained in:
committed by
Michal Pristas
parent
89c09b11f8
commit
e5b307354c
@@ -22,7 +22,7 @@ func Test_Filter(t *testing.T) {
|
||||
|
||||
func (t *FilterTests) Test_IgnoreSimple() {
|
||||
r := t.Require()
|
||||
conf := config.GetConfLogErr(testConfigFile, t.T())
|
||||
conf := GetConfLogErr(testConfigFile, t.T())
|
||||
f := NewFilter(conf.FilterFile)
|
||||
f.AddRule("github.com/a/b", Exclude)
|
||||
|
||||
@@ -35,7 +35,7 @@ func (t *FilterTests) Test_IgnoreSimple() {
|
||||
|
||||
func (t *FilterTests) Test_IgnoreParentAllowChildren() {
|
||||
r := t.Require()
|
||||
conf := config.GetConfLogErr(testConfigFile, t.T())
|
||||
conf := GetConfLogErr(testConfigFile, t.T())
|
||||
f := NewFilter(conf.FilterFile)
|
||||
f.AddRule("github.com/a/b", Exclude)
|
||||
f.AddRule("github.com/a/b/c", Include)
|
||||
@@ -50,7 +50,7 @@ func (t *FilterTests) Test_IgnoreParentAllowChildren() {
|
||||
func (t *FilterTests) Test_OnlyAllowed() {
|
||||
r := t.Require()
|
||||
|
||||
conf := config.GetConfLogErr(testConfigFile, t.T())
|
||||
conf := GetConfLogErr(testConfigFile, t.T())
|
||||
f := NewFilter(conf.FilterFile)
|
||||
f.AddRule("github.com/a/b", Include)
|
||||
f.AddRule("", Exclude)
|
||||
@@ -65,7 +65,7 @@ func (t *FilterTests) Test_OnlyAllowed() {
|
||||
func (t *FilterTests) Test_Direct() {
|
||||
r := t.Require()
|
||||
|
||||
conf := config.GetConfLogErr(testConfigFile, t.T())
|
||||
conf := GetConfLogErr(testConfigFile, t.T())
|
||||
f := NewFilter(conf.FilterFile)
|
||||
f.AddRule("github.com/a/b/c", Exclude)
|
||||
f.AddRule("github.com/a/b", Direct)
|
||||
@@ -76,3 +76,14 @@ func (t *FilterTests) Test_Direct() {
|
||||
r.Equal(Direct, f.Rule("github.com/a/b"))
|
||||
r.Equal(Exclude, f.Rule("github.com/a/b/c/d"))
|
||||
}
|
||||
|
||||
// GetConfLogErr is similar to GetConf, except it logs a failure for the calling test
|
||||
// if any errors are encountered
|
||||
func GetConfLogErr(path string, t *testing.T) *config.Config {
|
||||
c, err := config.GetConf(path)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to parse config file: %s", err.Error())
|
||||
return nil
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user