-
Notifications
You must be signed in to change notification settings - Fork 0
/
header_test.go
59 lines (48 loc) · 1.1 KB
/
header_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
58
59
package ar
import (
"os"
"path"
"testing"
"time"
)
func TestFileInfoHeader(t *testing.T) {
info, err := os.Stat(os.Args[0])
if err != nil {
t.Fatal(err)
}
header := FileInfoHeader(info)
if header.Name != info.Name() {
t.Error("Header name doesn't match file info.")
}
if header.ModTime != info.ModTime() {
t.Error("Header modtime doesn't match file info.")
}
if header.Mode != int64(info.Mode()) {
t.Error("Header mode doesn't match file info.")
}
if header.Size != info.Size() {
t.Error("Header size doesn't match file info.")
}
}
func TestFileInfo(t *testing.T) {
now := time.Now()
header := &Header{
Name: "testdata/test.o",
ModTime: now,
Mode: int64(os.ModePerm | os.ModeDir),
Size: 5,
}
info := header.FileInfo()
if info.Name() != path.Base(header.Name) {
t.Error("Info name doesn't match header.")
}
if info.ModTime() != header.ModTime {
t.Error("Info modtime doesn't match header.")
}
if int64(info.Mode()) != header.Mode {
t.Error("Header mode doesn't match header.")
}
if info.Size() != header.Size {
t.Error("Size size doesn't match header.")
}
}