shad-go/distbuild/pkg/build/cmd_test.go

32 lines
596 B
Go
Raw Normal View History

2020-03-23 20:58:08 +00:00
package build
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCmdRender(t *testing.T) {
tmpl := Cmd{
CatOutput: "{{.OutputDir}}/import.map",
CatTemplate: `bytes={{index .Deps "6100000000000000000000000000000000000000"}}/lib.a`,
}
ctx := JobContext{
OutputDir: "/distbuild/jobs/b",
Deps: map[ID]string{
{'a'}: "/distbuild/jobs/a",
},
}
result, err := tmpl.Render(ctx)
require.NoError(t, err)
expected := &Cmd{
CatOutput: "/distbuild/jobs/b/import.map",
CatTemplate: "bytes=/distbuild/jobs/a/lib.a",
}
require.Equal(t, expected, result)
}