-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: incorrectly blocking versioned modules
- Loading branch information
1 parent
194c827
commit abc6380
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package gomodguard | ||
|
||
import "testing" | ||
|
||
func TestIsModuleBlocked(t *testing.T) { | ||
var tests = []struct { | ||
testName string | ||
processor Processor | ||
testModule string | ||
}{ | ||
{ | ||
"previous version blocked", | ||
Processor{ | ||
blockedModulesFromModFile: map[string][]string{ | ||
"github.com/foo/bar": {blockReasonNotInAllowedList}, | ||
}, | ||
}, | ||
"github.com/foo/bar/v2", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.testName, func(t *testing.T) { | ||
blockReasons := tt.processor.isBlockedPackageFromModFile(tt.testModule) | ||
if len(blockReasons) > 0 { | ||
t.Logf("Testing %v, expected allowed, was blocked: %v", tt.testModule, blockReasons) | ||
t.Fail() | ||
} | ||
}) | ||
} | ||
} |