Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions mod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,28 @@ func TestGoSum_NoBannedDependencies(t *testing.T) {
}
require.NoError(t, scanner.Err())
}

func TestIsBannedModule(t *testing.T) {
tests := []struct {
name string
modPath string
wantBan string
wantOk bool
}{
{"exact match", "github.com/tendermint/tendermint", "github.com/tendermint/tendermint", true},
{"version suffix", "github.com/cosmos/ibc-go/v6", "github.com/cosmos/ibc-go", true},
{"prefix only", "github.com/tendermint/tm-db", "", false},
{"empty string", "", "", false},
{"unrelated module", "github.com/ethereum/go-ethereum", "", false},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotBan, gotOk := isBannedModule(tt.modPath)
require.Equal(t, tt.wantOk, gotOk)
if gotOk {
require.Equal(t, tt.wantBan, gotBan)
}
})
}
}