package handlers

import (
	"testing"

	"github.com/rancherio/go-rancher/client"
)

func TestBuildContainerConfig(t *testing.T) {
	machine := new(client.Machine)

	machine.ExternalId = "externalId"
	labels := make(map[string]interface{})

	labels["abc"] = "def"
	labels["foo"] = "bar"

	machine.Labels = labels
	config := buildContainerConfig([]string{}, machine, "rancher/agent", "0.7.8")

	for _, elem := range config.Env {
		if elem == "CATTLE_HOST_LABELS=abc=def&foo=bar" {
			return
		}
	}
	t.Error("label is not being set!")
}

package handlers

import (
	"testing"

	"github.com/rancherio/go-rancher/client"
)

func TestBuildContainerConfig(t *testing.T) {
	machine := new(client.Machine)

	machine.ExternalId = "externalId"
	labels := make(map[string]interface{})

	labels["abc"] = "def"
	labels["foo"] = "bar"

	machine.Labels = labels
	config := buildContainerConfig([]string{}, machine, "rancher/agent", "0.7.8")

	for _, elem := range config.Env {
		if elem == "CATTLE_HOST_LABELS=abc=def&foo=bar" || elem == "CATTLE_HOST_LABELS=foo=bar&abc=def" {
			return
		}
	}
	t.Error("label is not being set!")
}

Make test insensitive to param order
Make test insensitive to param order

TestBuildContainerConfig checks for the existence of a certain label,
but it was sensitive to the order of the parameters in the value of the
label. This makes it insensitive to the order
