package fileop import ( "fmt" "os" "porg/testutil" "testing" ) func TestMove(t *testing.T) { src := testutil.CreateTmpFile() dest := fmt.Sprintf("/tmp/%s", testutil.RandomString(10)) c := Move() c <- &MoveCommand{Source: src, Destination: dest} close(c) if _, err := os.Stat(dest); err != nil { t.Errorf("File %s not moved to %s", src, dest) } } func TestIsEmpty(t *testing.T) { folder := testutil.CreateFolder() empty, err := IsEmpty(folder) if err != nil { t.Fatalf("Error reading the folder %s", err.Error()) } if !empty { t.Errorf("Folder is not empty %s", folder) } } func TestCalculateSHA256(t *testing.T) { if f, err := os.Open("test_file.txt"); err != nil { t.Error(err) } else { sh256, _ := CalculateSHA256(f) if sh256 != "027cc886f9b8c866f932ef8b8da9a32f0857ef8e16ec98dd2797021b34623b88" { t.Errorf("Wrong sh256 hash, given %s", sh256) } } }