@@ -7,11 +7,11 @@ import (
7
7
"net/http"
8
8
"os"
9
9
"path/filepath"
10
+ "syscall"
10
11
"testing"
11
12
12
13
"github.com/spf13/afero"
13
14
"github.com/stretchr/testify/require"
14
- "golang.org/x/xerrors"
15
15
16
16
"github.com/coder/coder/v2/agent"
17
17
"github.com/coder/coder/v2/agent/agenttest"
@@ -48,11 +48,19 @@ func (fs *testFs) Create(name string) (afero.File, error) {
48
48
// lets you nest them underneath files, somehow.
49
49
stat , err := fs .Fs .Stat (name )
50
50
if err == nil && stat .IsDir () {
51
- return nil , xerrors .New ("is a directory" )
51
+ return nil , & os.PathError {
52
+ Op : "open" ,
53
+ Path : name ,
54
+ Err : syscall .EISDIR ,
55
+ }
52
56
}
53
57
stat , err = fs .Fs .Stat (filepath .Dir (name ))
54
58
if err == nil && ! stat .IsDir () {
55
- return nil , xerrors .New ("not a directory" )
59
+ return nil , & os.PathError {
60
+ Op : "open" ,
61
+ Path : name ,
62
+ Err : syscall .ENOTDIR ,
63
+ }
56
64
}
57
65
return fs .Fs .Create (name )
58
66
}
@@ -65,11 +73,19 @@ func (fs *testFs) MkdirAll(name string, mode os.FileMode) error {
65
73
// lets you nest them underneath files somehow.
66
74
stat , err := fs .Fs .Stat (filepath .Dir (name ))
67
75
if err == nil && ! stat .IsDir () {
68
- return xerrors .New ("not a directory" )
76
+ return & os.PathError {
77
+ Op : "mkdir" ,
78
+ Path : name ,
79
+ Err : syscall .ENOTDIR ,
80
+ }
69
81
}
70
82
stat , err = fs .Fs .Stat (name )
71
83
if err == nil && ! stat .IsDir () {
72
- return xerrors .New ("not a directory" )
84
+ return & os.PathError {
85
+ Op : "mkdir" ,
86
+ Path : name ,
87
+ Err : syscall .ENOTDIR ,
88
+ }
73
89
}
74
90
return fs .Fs .MkdirAll (name , mode )
75
91
}
0 commit comments