github.com/rita33cool1/iot-system-gateway@v0.0.0-20200911033302-e65bde238cc5/docker-engine/builder/dockerfile/builder_test.go (about)

     1  package dockerfile // import "github.com/docker/docker/builder/dockerfile"
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/docker/docker/builder/dockerfile/parser"
     8  	"github.com/gotestyourself/gotestyourself/assert"
     9  	is "github.com/gotestyourself/gotestyourself/assert/cmp"
    10  )
    11  
    12  func TestAddNodesForLabelOption(t *testing.T) {
    13  	dockerfile := "FROM scratch"
    14  	result, err := parser.Parse(strings.NewReader(dockerfile))
    15  	assert.Check(t, err)
    16  
    17  	labels := map[string]string{
    18  		"org.e": "cli-e",
    19  		"org.d": "cli-d",
    20  		"org.c": "cli-c",
    21  		"org.b": "cli-b",
    22  		"org.a": "cli-a",
    23  	}
    24  	nodes := result.AST
    25  	addNodesForLabelOption(nodes, labels)
    26  
    27  	expected := []string{
    28  		"FROM scratch",
    29  		`LABEL "org.a"='cli-a' "org.b"='cli-b' "org.c"='cli-c' "org.d"='cli-d' "org.e"='cli-e'`,
    30  	}
    31  	assert.Check(t, is.Len(nodes.Children, 2))
    32  	for i, v := range nodes.Children {
    33  		assert.Check(t, is.Equal(expected[i], v.Original))
    34  	}
    35  }