github.com/influx6/npkg@v0.8.8/nfs/filesytem_test.go (about) 1 package nfs_test 2 3 import ( 4 "testing" 5 6 filesystem "github.com/influx6/npkg/nfs" 7 tests "github.com/influx6/npkg/ntests" 8 ) 9 10 func TestFileSystemGroup(t *testing.T) { 11 g := filesystem.VirtualFileSystem{ 12 GetFileFunc: getFileFunc, 13 } 14 b := filesystem.VirtualFileSystem{ 15 GetFileFunc: getFileFunc, 16 } 17 18 gs := filesystem.NewSystemGroup() 19 if err := gs.Register("/static/", g); err != nil { 20 tests.Failed("Should have succesffully registered nfs for /static/") 21 } 22 tests.Passed("Should have succesffully registered nfs for /static/") 23 24 if err := gs.Register("/thunder", b); err != nil { 25 tests.Failed("Should have succesffully registered nfs for /thunder") 26 } 27 tests.Passed("Should have succesffully registered nfs for /thunder") 28 29 if err := gs.Register("/static/css", b); err != nil { 30 tests.Failed("Should have succesffully registered nfs for /static/css") 31 } 32 tests.Passed("Should have succesffully registered nfs for /static/css") 33 34 if _, err := gs.Open("/static/"); err != nil { 35 tests.Failed("Should have succeeded in retrieving dir") 36 } 37 tests.Passed("Should have succeeded in retrieving dir") 38 39 if _, err := gs.Open("/static/css"); err != nil { 40 tests.Failed("Should have succeeded in retrieving dir") 41 } 42 tests.Passed("Should have succeeded in retrieving dir") 43 44 if _, err := gs.Open("/thunder"); err != nil { 45 tests.Failed("Should have succeeded in retrieving dir") 46 } 47 tests.Passed("Should have succeeded in retrieving dir") 48 49 if _, err := gs.Open("/static/wombat.css"); err != nil { 50 tests.Failed("Should have succeeded to retrieve any file: %+q", err) 51 } 52 tests.Passed("Should have succeeded to retrieve any fileq") 53 54 if _, err := gs.Open("/thunder/wombat.css"); err != nil { 55 tests.Failed("Should have succeeded to retrieve any file: %+q", err) 56 } 57 tests.Passed("Should have succeeded to retrieve any fileq") 58 59 if _, err := gs.Open("/static/css/wombat.css"); err != nil { 60 tests.Failed("Should have succeeded to retrieve any file: %+q", err) 61 } 62 tests.Passed("Should have succeeded to retrieve any fileq") 63 64 } 65 66 func getFileFunc(path string) (filesystem.File, error) { 67 return &filesystem.VirtualFile{}, nil 68 }