lib9p

Go 9P library.
Log | Files | Refs | LICENSE

uid_test.go (608B)


      1 package lib9p
      2 
      3 import (
      4 	"io/fs"
      5 	"testing"
      6 )
      7 
      8 func TestHasPerm(t *testing.T) {
      9 	tests := []struct {
     10 		st   Stat
     11 		uid  string
     12 		perm fs.FileMode
     13 		want bool
     14 	}{
     15 		{Stat{Mode: 0777, Uid: "gotoh", Gid: "kessoku"}, "gotoh", 04, true},
     16 		{Stat{Mode: 0770, Uid: "gotoh", Gid: "kessoku"}, "ijichi", 04, true},
     17 		{Stat{Mode: 0000, Uid: "gotoh", Gid: "kessoku"}, "gotoh", 04, false},
     18 	}
     19 	for i, test := range tests {
     20 		if got := hasPerm(testfs, &FileInfo{test.st}, test.uid, test.perm); got != test.want {
     21 			t.Errorf("hasPerm(pfs, file[%d], %s, 0%o) == %t\n",
     22 				i, test.uid, test.perm, got)
     23 			continue
     24 		}
     25 	}
     26 }