-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rafi <[email protected]>
- Loading branch information
Showing
2 changed files
with
57 additions
and
4 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
32 changes: 32 additions & 0 deletions
32
cmd/devguard-scanner/commands/intoto/intoto_record_test.go
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,32 @@ | ||
package intotocmd | ||
|
||
import ( | ||
"os" | ||
"path" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseGitIgnore(t *testing.T) { | ||
t.Run("parseGitIgnore with empty strings", func(t *testing.T) { | ||
// create temp dir for testing | ||
dir, err := os.MkdirTemp("", "test") | ||
assert.NoError(t, err, "failed to create temporary directory") | ||
|
||
defer os.RemoveAll(dir) | ||
|
||
// Create a temporary .gitignore file for testing | ||
gitignoreContent := "\n.DS_Store\n\t\t\t\n" | ||
|
||
filepath := path.Join(dir, ".gitignore") | ||
|
||
err = os.WriteFile(filepath, []byte(gitignoreContent), 0644) | ||
assert.NoError(t, err, "failed to create temporary .gitignore file") | ||
|
||
ignorePaths, err := parseGitIgnore(filepath) | ||
assert.NoError(t, err, "expected no error when reading .gitignore") | ||
assert.Equal(t, []string{".DS_Store"}, ignorePaths, "unexpected ignore paths") | ||
|
||
}) | ||
} |