moby/builder/dockerfile/builder_test.go
Daniel Nephin 64c4c1c3d5 Keep parser.Directive internal to parser
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-04-12 14:48:09 -04:00

34 lines
775 B
Go

package dockerfile
import (
"strings"
"testing"
"github.com/docker/docker/builder/dockerfile/parser"
"github.com/docker/docker/pkg/testutil/assert"
)
func TestAddNodesForLabelOption(t *testing.T) {
dockerfile := "FROM scratch"
result, err := parser.Parse(strings.NewReader(dockerfile))
assert.NilError(t, err)
labels := map[string]string{
"org.e": "cli-e",
"org.d": "cli-d",
"org.c": "cli-c",
"org.b": "cli-b",
"org.a": "cli-a",
}
nodes := result.AST
addNodesForLabelOption(nodes, labels)
expected := []string{
"FROM scratch",
`LABEL "org.a"='cli-a' "org.b"='cli-b' "org.c"='cli-c' "org.d"='cli-d' "org.e"='cli-e'`,
}
assert.Equal(t, len(nodes.Children), 2)
for i, v := range nodes.Children {
assert.Equal(t, v.Original, expected[i])
}
}