Shit ton of tests
This commit is contained in:
parent
99b00887a8
commit
ccf98c2f6e
13 changed files with 1157 additions and 1 deletions
27
embedFsWrapper/wrapper_test.go
Normal file
27
embedFsWrapper/wrapper_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package embedFsWrapper_test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"testing"
|
||||
"testing/fstest"
|
||||
|
||||
"git.mstar.dev/mstar/goutils/embedFsWrapper"
|
||||
)
|
||||
|
||||
func TestFSWrapper(t *testing.T) {
|
||||
mfs := fstest.MapFS{
|
||||
"baz/foo": &fstest.MapFile{Data: []byte("bar")},
|
||||
}
|
||||
wrapped := embedFsWrapper.NewFSWrapper(mfs, "baz/")
|
||||
f, err := wrapped.Open("foo")
|
||||
if err != nil {
|
||||
t.Fatalf("Expected to open file foo (baz/foo), got %v", err)
|
||||
}
|
||||
data, err := io.ReadAll(f)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(data) != "bar" {
|
||||
t.Fatalf("Expected file to have \"bar\" as content, found %v", string(data))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue