Skip to content

Commit

Permalink
⚡ QD-9824 Fix paths for Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avafanasiev committed Aug 31, 2024
1 parent ff9941a commit 487d12f
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions platform/git_changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ func createRepo(t *testing.T, tc TestConfig) string {
// File name
fileName := "file.txt"
fileName2 := "file2.txt"
absolutePath := filepath.Join(repoDir, fileName)
absolutePath2 := filepath.Join(repoDir, fileName2)

// Step 3: Create the first file and commit it if initial content is not empty
initialFileName := fileName
if tc.initialContent == "" {
initialFileName = "file2.txt"
}
err = os.WriteFile(repoDir+"/"+initialFileName, []byte(tc.initialContent), 0644)
err = os.WriteFile(filepath.Join(repoDir, initialFileName), []byte(tc.initialContent), 0644)
assert.NoError(t, err)

cmd = exec.Command("git", "add", initialFileName)
Expand All @@ -203,21 +205,18 @@ func createRepo(t *testing.T, tc TestConfig) string {
// Step 4: Perform the action specified
switch tc.action {
case "modify":
err = os.WriteFile(repoDir+"/"+fileName, []byte(tc.modifiedContent), 0644)
err = os.WriteFile(absolutePath, []byte(tc.modifiedContent), 0644)
assert.NoError(t, err)
case "move":
cmd = exec.Command("git", "mv", repoDir+"/"+fileName, repoDir+"/"+fileName2)
cmd = exec.Command("git", "mv", absolutePath, absolutePath2)
cmd.Dir = repoDir
err = cmd.Run()
assert.NoError(t, err)
//err = os.Remove(repoDir + "/" + fileName)
//err = os.WriteFile(repoDir+"/"+fileName2, []byte(tc.modifiedContent), 0644)
//assert.NoError(t, err)
case "delete":
err = os.Remove(repoDir + "/" + fileName)
err = os.Remove(absolutePath)
assert.NoError(t, err)
case "create":
err = os.WriteFile(repoDir+"/"+fileName, []byte(tc.modifiedContent), 0644)
err = os.WriteFile(absolutePath, []byte(tc.modifiedContent), 0644)
assert.NoError(t, err)
}

Expand All @@ -234,11 +233,3 @@ func createRepo(t *testing.T, tc TestConfig) string {

return repoDir
}

func getCurrentHash(t *testing.T, repoDir string) string {
cmd := exec.Command("git", "rev-parse", "HEAD")
cmd.Dir = repoDir
out, err := cmd.Output()
assert.NoError(t, err)
return string(out)
}

0 comments on commit 487d12f

Please sign in to comment.