vise/go/engine/loop_test.go

45 lines
843 B
Go

package engine
import (
"bytes"
"context"
"log"
"strings"
"testing"
"git.defalsify.org/festive/cache"
"git.defalsify.org/festive/resource"
"git.defalsify.org/festive/state"
)
func TestLoopCorrect(t *testing.T) {
generateTestData(t)
ctx := context.TODO()
st := state.NewState(0)
//rs := NewFsWrapper(dataDir, &st)
rs := resource.NewFsResource(dataDir)
ca := cache.NewCache().WithCacheSize(1024)
en := NewEngine(&st, &rs, ca)
err := en.Init("root", ctx)
if err != nil {
t.Fatal(err)
}
input := []string{
"1",
"0",
"1",
"0",
}
inputStr := strings.Join(input, "\n")
inputBuf := bytes.NewBuffer(append([]byte(inputStr), 0x0a))
outputBuf := bytes.NewBuffer(nil)
log.Printf("running with input: %s", inputBuf.Bytes())
err = Loop(&en, "root", ctx, inputBuf, outputBuf)
if err != nil {
t.Fatal(err)
}
}