Add a dry run flag
This commit is contained in:
@@ -394,6 +394,35 @@ func TestLinkInstruction_RunAsync(t *testing.T) {
|
||||
assert.Contains(t, err.Error(), "files=true")
|
||||
assert.True(t, FileExists(targetDir))
|
||||
})
|
||||
|
||||
t.Run("Dry run does not modify filesystem", func(t *testing.T) {
|
||||
originalFS := filesystem
|
||||
filesystem = NewDryRunFileSystem()
|
||||
defer func() {
|
||||
filesystem = originalFS
|
||||
}()
|
||||
|
||||
target := filepath.Join(testDir, "dryrun-link.txt")
|
||||
instruction := LinkInstruction{
|
||||
Source: srcFile,
|
||||
Target: target,
|
||||
Force: true,
|
||||
Delete: true,
|
||||
}
|
||||
|
||||
status := make(chan error)
|
||||
go instruction.RunAsync(status)
|
||||
|
||||
err := <-status
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, FileExists(target))
|
||||
|
||||
summary := filesystem.SummaryLines()
|
||||
assert.Equal(t, 1, len(summary))
|
||||
assert.Contains(t, summary[0], "DRY-RUN")
|
||||
assert.Contains(t, summary[0], srcFile)
|
||||
assert.Contains(t, summary[0], target)
|
||||
})
|
||||
}
|
||||
|
||||
func TestLinkInstruction_Undo(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user