MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestFilesystem

Function TestFilesystem

pkg/fetch/fs_test.go:46–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

44}
45
46func TestFilesystem(t *testing.T) {
47 a := assertions.New(t)
48 filename := "file"
49 content := []byte("Hello world")
50
51 fs, err := createMockFileSystem()
52 a.So(err, should.BeNil)
53 defer fs.Destroy()
54
55 // Creating working file
56 {
57 f, err := os.Create(filepath.Join(fs.Dir(), filename))
58 a.So(err, should.BeNil)
59
60 _, err = f.Write(content)
61 a.So(err, should.BeNil)
62 err = f.Close()
63 a.So(err, should.BeNil)
64 }
65
66 fetcher := fetch.FromFilesystem(fs.Dir())
67
68 // Reading working file
69 {
70 fileContent, err := fetcher.File(filename)
71 a.So(err, should.BeNil)
72 a.So(string(fileContent), should.Equal, string(content))
73 }
74
75 // Reading non-working file
76 {
77 _, err = fetcher.File("non-existing file")
78 a.So(err, should.NotBeNil)
79 }
80}

Callers

nothing calls this directly

Calls 10

FromFilesystemFunction · 0.92
createMockFileSystemFunction · 0.85
DestroyMethod · 0.80
DirMethod · 0.80
NewMethod · 0.65
CreateMethod · 0.65
JoinMethod · 0.65
CloseMethod · 0.65
FileMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected