Skip to content

Commit

Permalink
Merge branch 'main' into wasmtransformer
Browse files Browse the repository at this point in the history
  • Loading branch information
HarikrishnanBalagopal authored Jan 4, 2024
2 parents 1a3e656 + 17a115d commit 5e9ad3d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions filesystem/merger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package filesystem
import (
"os"
"testing"
"io/ioutil"
)

func TestMergeDeletionCallBack(t *testing.T) {
Expand Down Expand Up @@ -48,3 +49,47 @@ func TestMergeDeletionCallBack(t *testing.T) {

})
}

func TestMergeProcessFileCallBack_SameContent(t *testing.T) {
t.Run("test for source and destination files with same content", func(t *testing.T) {
nonExistentPath := ""

sourceFile, err := ioutil.TempFile(nonExistentPath, "source")
if err != nil {
t.Fatalf("Failed to create source file: %v", err)
}
defer os.Remove(sourceFile.Name())

destinationFile, err := ioutil.TempFile(nonExistentPath , "destination")
if err != nil {
t.Fatalf("Failed to create destination file: %v", err)
}
defer os.Remove(destinationFile.Name())

// Write content to both files
content := "same content"
_, err = sourceFile.WriteString(content)
if err != nil {
t.Fatalf("Failed to write to source file: %v", err)
}
_, err = destinationFile.WriteString(content)
if err != nil {
t.Fatalf("Failed to write to destination file: %v", err)
}


err = mergeProcessFileCallBack(sourceFile.Name(), destinationFile.Name(), false)
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}

// Assert that the destination file content is not updated
updatedContent, err := ioutil.ReadFile(destinationFile.Name())
if err != nil {
t.Fatalf("Failed to read destination file: %v", err)
}
if string(updatedContent) != content {
t.Errorf("Destination file content should not be updated")
}
})
}

0 comments on commit 5e9ad3d

Please sign in to comment.