feat: add run result
This commit is contained in:
28
chain_processor_test.go
Normal file
28
chain_processor_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package script
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestChain(t *testing.T) {
|
||||
p := func(_ context.Context, in []string) ([]string, error) {
|
||||
in[0] = in[0] + in[0]
|
||||
return in, nil
|
||||
}
|
||||
|
||||
chain := Chain(p, p, p)
|
||||
|
||||
in := []string{"a"}
|
||||
want := []string{"aaaaaaaa"}
|
||||
|
||||
res, err := chain(t.Context(), in)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !slices.Equal(res, want) {
|
||||
t.Fatalf("slices are not equal, have: %+v, want: %+v", res, want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user