Skip to content

Commit

Permalink
EVENT: Add test case for file removal after successful copy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cian911 committed Jan 23, 2022
1 parent 96e92e9 commit d9160b9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions event/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func TestEvent(t *testing.T) {
if _, err := os.Stat(fmt.Sprintf("%s/%s", event.Destination, event.File)); errors.Is(err, os.ErrNotExist) {
t.Fatalf("Failed to move from %s/%s to %s/%s: %v : %v", event.Path, event.File, event.Destination, event.File, err, *event)
}

// If the file still exists in the source directory, log an error
if _, err := os.Stat(fmt.Sprintf("%s/%s", event.Path, event.File)); !errors.Is(err, os.ErrNotExist) {
t.Fatalf("Failed to delete file from %s/%s to %s/%s after Move: %v : %v", event.Path, event.File, event.Destination, event.File, err, *event)
}
})

t.Run("It moves file from one dir to another dir with valid destPath", func(t *testing.T) {
Expand All @@ -59,6 +64,11 @@ func TestEvent(t *testing.T) {
if _, err := os.Stat(fmt.Sprintf("%s/%s", event.Destination, event.File)); errors.Is(err, os.ErrNotExist) {
t.Fatalf("Failed to move from %s/%s to %s/%s: %v : %v", event.Path, event.File, event.Destination, event.File, err, *event)
}

// If the file still exists in the source directory, log an error
if _, err := os.Stat(fmt.Sprintf("%s/%s", event.Path, event.File)); !errors.Is(err, os.ErrNotExist) {
t.Fatalf("Failed to delete file from %s/%s to %s/%s after Move: %v : %v", event.Path, event.File, event.Destination, event.File, err, *event)
}
})

t.Run("It does not move file from one dir to another dir", func(t *testing.T) {
Expand Down

0 comments on commit d9160b9

Please sign in to comment.