-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for getBlobsFromChannel (#204)
- Loading branch information
Showing
1 changed file
with
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package scanner | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func Test_getBlobsFromChannel(t *testing.T) { | ||
ch := make(chan []string) | ||
go func() { | ||
ch <- []string{ | ||
"100644 blob 351324aa7b3c66043e484c2f2c7b7f1842152f35 .gitignore", | ||
"100644 blob 8715df9907604c8ee8fc5e377821817f84f014fa .pre-commit-hooks.yaml", | ||
"commitSha", | ||
} | ||
}() | ||
blobsInCommits := BlobsInCommits{commits: map[string][]string{}} | ||
getBlobsFromChannel(blobsInCommits, ch) | ||
|
||
commits := blobsInCommits.commits | ||
assert.Len(t, commits, 2) | ||
assert.Equal(t, []string{"commitSha"}, commits["351324aa7b3c66043e484c2f2c7b7f1842152f35 .gitignore"]) | ||
assert.Equal(t, []string{"commitSha"}, commits["8715df9907604c8ee8fc5e377821817f84f014fa .pre-commit-hooks.yaml"]) | ||
} |