Skip to content

Commit

Permalink
compute ignoreconfigs for scan mode with ignore history
Browse files Browse the repository at this point in the history
  • Loading branch information
Divya Uppu authored and svishwanath-tw committed Sep 13, 2022
1 parent 5a56feb commit de9baca
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions talismanrc/talismanrc.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,10 @@ func For(mode Mode) *TalismanRC {
talismanRC := fromPersistedRC(configFromTalismanRCFile, mode)
return talismanRC
}

func ForScan(ignoreHistory bool) *TalismanRC {
if ignoreHistory {
return For(HookMode)
}
return For(ScanMode)
}
29 changes: 29 additions & 0 deletions talismanrc/talismanrc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,33 @@ func TestFor(t *testing.T) {
assert.True(t, rc.IgnoreConfigs[2].ChecksumMatches("file3_checksum"))

})


}

func TestForScan(t *testing.T) {
var repoFileReader = func(string) ([]byte, error) {
return []byte(`fileignoreconfig:
- filename: testfile_1.yml
checksum: file1_checksum
- filename: testfile_2.yml
checksum: file2_checksum
- filename: testfile_3.yml
checksum: file3_checksum`), nil
}
t.Run("talismanrc.ForScan(ignoreHistory) should populate talismanrc for scan mode with ignore history", func(t *testing.T) {
setRepoFileReader(repoFileReader)
rc := ForScan(true)

assert.Equal(t, 3, len(rc.IgnoreConfigs))

})

t.Run("talismanrc.ForScan(ignoreHistory) should populate talismanrc for scan mode without ignore history", func(t *testing.T) {
setRepoFileReader(repoFileReader)
rc := ForScan(false)

assert.Equal(t, 0, len(rc.IgnoreConfigs))

})
}

0 comments on commit de9baca

Please sign in to comment.