Skip to content

Commit

Permalink
added a test for cloning a single file
Browse files Browse the repository at this point in the history
  • Loading branch information
scrouthtv committed Oct 10, 2021
1 parent fdc5bf4 commit 947ea78
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
41 changes: 41 additions & 0 deletions full_test/duplicate_renaming_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package full_test

import (
"easy-copy/fs"
"testing"
)

func TestDuplicateRenaming(t *testing.T) {
is := fs.CreateFS([]string{
"foo/a",
"bar/",
})

should := fs.CreateFS([]string{
"foo/a",
"bar/b",
})

t.Log("before copying:")
for _, v := range is.Tree() {
t.Log(v)
}

line := "cp foo/a bar/b --debug"

test := NewTest(line)
test.is = is
test.should = should

test.Run(t)

t.Log("after copying:")
for _, v := range is.Tree() {
t.Log(v)
}

ok, badpath := is.Equal(should)
if !ok {
t.Error("fs differs:", badpath)
}
}
13 changes: 12 additions & 1 deletion full_test/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,22 @@ func NewTest(line string) *TestSetup {
return &TestSetup{line: line}
}

func reset() {
progress.IteratorDone = false
progress.CopyDone = false
progress.DoneAmount = 0
progress.FullAmount = 0
progress.DoneSize = 0
progress.FullSize = 0
}

// Run runs the software with the arguments in t.line.
// It fails if a warning occurs.
func (test *TestSetup) Run(t *testing.T) {
t.Helper()

reset()

go func() {
for !progress.CopyDone {
select {
Expand All @@ -46,6 +57,6 @@ func (test *TestSetup) Run(t *testing.T) {

test.is.Rewind()
iterator.Iterate()
tasks.PrintTasks()
t.Log(" -- Starting loop -- ")
tasks.CopyLoop()
}

0 comments on commit 947ea78

Please sign in to comment.