-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirent_test.go
66 lines (58 loc) · 1.31 KB
/
dirent_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
60
61
62
63
64
65
66
// SPDX-FileCopyrightText: 2022 Weston Schmidt <[email protected]>
// SPDX-License-Identifier: Apache-2.0
package githubfs
import (
"io/fs"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestDirEntry_All(t *testing.T) {
tests := []struct {
description string
name string
size int64
time time.Time
mode fs.FileMode
isDir bool
}{
{
description: "file test",
name: "foo",
size: 1234,
time: time.Now(),
isDir: false,
}, {
description: "dir test",
name: "dir",
size: 0,
time: time.Now(),
isDir: true,
mode: fs.ModeDir,
},
}
for _, tc := range tests {
t.Run(tc.description, func(t *testing.T) {
assert := assert.New(t)
de := dirEntry{
info: &fileInfo{
name: tc.name,
size: tc.size,
modTime: tc.time,
mode: tc.mode,
},
}
assert.Equal(tc.name, de.Name())
assert.Equal(tc.mode, de.Type())
assert.Equal(tc.isDir, de.IsDir())
info, err := de.Info()
assert.NoError(err)
assert.Equal(tc.name, info.Name())
assert.Equal(tc.size, info.Size())
assert.Equal(tc.time, info.ModTime())
assert.Equal(tc.mode, info.Mode())
assert.Equal(tc.isDir, info.IsDir())
assert.Nil(info.Sys())
})
}
}