cloudinit/initialize/fleet_test.go
Alex Crawford ea1e4c38fa Revert "Merge pull request #234 from crawford/validate"
This reverts commit cdfc94f4e9, reversing
changes made to 2051cd3e1c.

Conflicts:
	config/config.go
	config/config_test.go
	config/etc_hosts.go
	config/etcd.go
	config/file.go
	config/fleet.go
	config/oem.go
	config/unit.go
	config/update.go
	config/user.go
	initialize/config.go
	initialize/config_test.go
	initialize/env.go
	initialize/manage_etc_hosts.go
	initialize/workspace.go
	system/env.go
	system/etc_hosts_test.go
	system/etcd.go
	system/etcd_test.go
	system/fleet.go
	system/fleet_test.go
	system/oem.go
	system/oem_test.go
	system/systemd.go
	system/update.go
	system/update_test.go
	test
2014-11-03 14:43:29 -08:00

44 lines
901 B
Go

package initialize
import "testing"
func TestFleetEnvironment(t *testing.T) {
cfg := make(FleetEnvironment, 0)
cfg["public-ip"] = "12.34.56.78"
env := cfg.String()
expect := `[Service]
Environment="FLEET_PUBLIC_IP=12.34.56.78"
`
if env != expect {
t.Errorf("Generated environment:\n%s\nExpected environment:\n%s", env, expect)
}
}
func TestFleetUnit(t *testing.T) {
cfg := make(FleetEnvironment, 0)
uu, err := cfg.Units("/")
if len(uu) != 0 {
t.Errorf("unexpectedly generated unit with empty FleetEnvironment")
}
cfg["public-ip"] = "12.34.56.78"
uu, err = cfg.Units("/")
if err != nil {
t.Errorf("error generating fleet unit: %v", err)
}
if len(uu) != 1 {
t.Fatalf("expected 1 unit generated, got %d", len(uu))
}
u := uu[0]
if !u.Runtime {
t.Errorf("bad Runtime for generated fleet unit!")
}
if !u.DropIn {
t.Errorf("bad DropIn for generated fleet unit!")
}
}