shad-go/distbuild/pkg/build/cmd_test.go
Fedor Korotkiy 6295c3f1a4 WIP
2020-03-27 22:56:55 +03:00

31 lines
596 B
Go

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)
}