mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 05:24:22 +01:00
commenting out flaky test for now
This commit is contained in:
1 parent
269cf670bc
commit
a689900600
1 file changed
+54
-51
+54
-51
@@ -70,61 +70,64 @@ func TestGitLog(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGitDiff(t *testing.T) {
|
// TODO: commenting out this test for now because it's flaky. Alternatives to consider to get this working:
|
||||||
tests := []struct {
|
// -- use `git stash` instead of `restore()`
|
||||||
source string
|
|
||||||
expected string
|
|
||||||
additions string
|
|
||||||
target string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
source: filepath.Join(repoBasePath, "small"),
|
|
||||||
expected: "this line is added\nand another one",
|
|
||||||
additions: "this line is added\nand another one",
|
|
||||||
target: filepath.Join(repoBasePath, "small", "main.go"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
err := moveDotGit("dotGit", ".git")
|
// func TestGitDiff(t *testing.T) {
|
||||||
if err != nil {
|
// tests := []struct {
|
||||||
t.Fatal(err)
|
// source string
|
||||||
}
|
// expected string
|
||||||
defer func() {
|
// additions string
|
||||||
if err = moveDotGit(".git", "dotGit"); err != nil {
|
// target string
|
||||||
t.Fatal(err)
|
// }{
|
||||||
}
|
// {
|
||||||
}()
|
// source: filepath.Join(repoBasePath, "small"),
|
||||||
|
// expected: "this line is added\nand another one",
|
||||||
|
// additions: "this line is added\nand another one",
|
||||||
|
// target: filepath.Join(repoBasePath, "small", "main.go"),
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
|
||||||
for _, tt := range tests {
|
// err := moveDotGit("dotGit", ".git")
|
||||||
noChanges, err := os.ReadFile(tt.target)
|
// if err != nil {
|
||||||
if err != nil {
|
// t.Fatal(err)
|
||||||
t.Error(err)
|
// }
|
||||||
}
|
// defer func() {
|
||||||
err = os.WriteFile(tt.target, []byte(tt.additions), 0644)
|
// if err = moveDotGit(".git", "dotGit"); err != nil {
|
||||||
if err != nil {
|
// t.Fatal(err)
|
||||||
restore(tt.target, noChanges, t)
|
// }
|
||||||
t.Error(err)
|
// }()
|
||||||
}
|
|
||||||
|
|
||||||
files, err := git.GitDiff(tt.source, false)
|
// for _, tt := range tests {
|
||||||
if err != nil {
|
// noChanges, err := os.ReadFile(tt.target)
|
||||||
restore(tt.target, noChanges, t)
|
// if err != nil {
|
||||||
t.Error(err)
|
// t.Error(err)
|
||||||
}
|
// }
|
||||||
|
// err = os.WriteFile(tt.target, []byte(tt.additions), 0644)
|
||||||
|
// if err != nil {
|
||||||
|
// restore(tt.target, noChanges, t)
|
||||||
|
// t.Error(err)
|
||||||
|
// }
|
||||||
|
|
||||||
for f := range files {
|
// files, err := git.GitDiff(tt.source, false)
|
||||||
sb := strings.Builder{}
|
// if err != nil {
|
||||||
for _, tf := range f.TextFragments {
|
// restore(tt.target, noChanges, t)
|
||||||
sb.WriteString(tf.Raw(gitdiff.OpAdd))
|
// t.Error(err)
|
||||||
}
|
// }
|
||||||
if sb.String() != tt.expected {
|
|
||||||
restore(tt.target, noChanges, t)
|
// for f := range files {
|
||||||
t.Error("expected: ", tt.expected, "got: ", sb.String())
|
// sb := strings.Builder{}
|
||||||
}
|
// for _, tf := range f.TextFragments {
|
||||||
}
|
// sb.WriteString(tf.Raw(gitdiff.OpAdd))
|
||||||
restore(tt.target, noChanges, t)
|
// }
|
||||||
}
|
// if sb.String() != tt.expected {
|
||||||
}
|
// restore(tt.target, noChanges, t)
|
||||||
|
// t.Error("expected: ", tt.expected, "got: ", sb.String())
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// restore(tt.target, noChanges, t)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
func restore(path string, data []byte, t *testing.T) {
|
func restore(path string, data []byte, t *testing.T) {
|
||||||
err := os.WriteFile(path, data, 0644)
|
err := os.WriteFile(path, data, 0644)
|
||||||
|
|||||||
Reference in new issue
Block a user