-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtarinator_test.go
57 lines (48 loc) · 941 Bytes
/
tarinator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package tarinator
import (
"io/ioutil"
"os"
"testing"
)
func TestArchive(t *testing.T) {
paths := []string{
"somescript.sh",
"test_files/",
}
err := Tarinate(paths, "output_test.tar.gz")
if err != nil {
t.Errorf("Failed: %s\n", err)
return
}
}
func TestOpen(t *testing.T) {
if _, err := os.Stat("output_test.tar.gz"); os.IsNotExist(err) {
t.Error("No file for untaring dected")
return
}
err := os.Mkdir("testing", 0755)
if err != nil {
os.RemoveAll("testing")
os.Mkdir("testing", 0755)
}
err = UnTarinate("testing", "output_test.tar.gz")
if err != nil {
t.Errorf("Failed untaring: %s\n", err)
return
}
files, err := ioutil.ReadDir("testing")
if err != nil {
t.Error(err)
return
}
if len(files) != 2 {
t.Errorf("The directory wasn't actually written")
}
}
func isDir(pth string) (bool, error) {
fi, err := os.Stat(pth)
if err != nil {
return false, err
}
return fi.IsDir(), nil
}