commit 5272a4535dd41a9fc5ca54f1eb57886e4e8edeb5
parent 37df65c28a10096bc5281584f859edacc27fd015
Author: Matsuda Kenji <info@mtkn.jp>
Date: Mon, 18 Dec 2023 11:48:59 +0900
update test for hasPerm
Diffstat:
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/server.go b/server.go
@@ -444,7 +444,7 @@ func sOpen(ctx context.Context, s *Server, r *Req) {
parentPath := path.Dir(r.Fid.path)
st, err := fs.Stat(ExportFS{s.fs}, parentPath)
if err != nil {
- Respond(ctx, r, fmt.Errorf("stat parent: %v"))
+ Respond(ctx, r, fmt.Errorf("stat parent: %v", err))
return
}
if !hasPerm(st, r.Fid.Uid, AWRITE) {
diff --git a/uid_test.go b/uid_test.go
@@ -36,7 +36,12 @@ func TestHasPerm(t *testing.T) {
}
for i, test := range tests {
- if got := hasPerm(test.file, test.uid, test.perm); got != test.want {
+ st, err := test.file.Stat()
+ if err != nil {
+ t.Errorf("file[%d].Stat(): %v", i, err)
+ continue
+ }
+ if got := hasPerm(st, test.uid, test.perm); got != test.want {
t.Errorf("hasPerm(file[%d], %s, 0%o) == %t\n",
i, test.uid, test.perm, got)
continue