(t *testing.T)
| 44 | } |
| 45 | |
| 46 | func 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 | } |
nothing calls this directly
no test coverage detected