2024-04-19 05:20:26 +00:00
|
|
|
package sideload
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/fs"
|
2024-04-21 18:38:12 +00:00
|
|
|
"strings"
|
2024-04-19 05:20:26 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"embed"
|
|
|
|
|
|
|
|
"git.foosoft.net/alex/goldsmith"
|
|
|
|
"git.foosoft.net/alex/goldsmith/harness"
|
|
|
|
)
|
|
|
|
|
2024-04-21 18:38:12 +00:00
|
|
|
//go:embed testdata/fs/source
|
2024-04-19 05:20:26 +00:00
|
|
|
var embedFs embed.FS
|
|
|
|
|
2024-04-21 18:38:12 +00:00
|
|
|
func TestFs(self *testing.T) {
|
|
|
|
harness.ValidateCase(
|
2024-04-19 05:20:26 +00:00
|
|
|
self,
|
2024-04-21 18:38:12 +00:00
|
|
|
"fs",
|
2024-04-19 05:20:26 +00:00
|
|
|
func(gs *goldsmith.Goldsmith) {
|
2024-04-21 18:38:12 +00:00
|
|
|
subFs, err := fs.Sub(embedFs, "testdata/fs/source")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2024-04-19 05:20:26 +00:00
|
|
|
gs.Chain(New().FileSystems(subFs))
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
2024-04-21 18:38:12 +00:00
|
|
|
|
|
|
|
func TestFile(self *testing.T) {
|
|
|
|
harness.ValidateCase(
|
|
|
|
self,
|
|
|
|
"file",
|
|
|
|
func(gs *goldsmith.Goldsmith) {
|
|
|
|
file := File{
|
|
|
|
Path: "hello.txt",
|
|
|
|
Reader: strings.NewReader("hello world"),
|
|
|
|
}
|
|
|
|
|
|
|
|
gs.Chain(New().Files(file))
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|