58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package system
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/coreos/coreos-cloudinit/config"
|
|
)
|
|
|
|
func TestEtcdUnits(t *testing.T) {
|
|
for _, tt := range []struct {
|
|
config config.Etcd
|
|
units []Unit
|
|
}{
|
|
{
|
|
config.Etcd{},
|
|
nil,
|
|
},
|
|
{
|
|
config.Etcd{
|
|
Discovery: "http://disco.example.com/foobar",
|
|
PeerBindAddr: "127.0.0.1:7002",
|
|
},
|
|
[]Unit{{config.Unit{
|
|
Name: "etcd.service",
|
|
Runtime: true,
|
|
DropIn: true,
|
|
Content: `[Service]
|
|
Environment="ETCD_DISCOVERY=http://disco.example.com/foobar"
|
|
Environment="ETCD_PEER_BIND_ADDR=127.0.0.1:7002"
|
|
`,
|
|
}}},
|
|
},
|
|
{
|
|
config.Etcd{
|
|
Name: "node001",
|
|
Discovery: "http://disco.example.com/foobar",
|
|
PeerBindAddr: "127.0.0.1:7002",
|
|
},
|
|
[]Unit{{config.Unit{
|
|
Name: "etcd.service",
|
|
Runtime: true,
|
|
DropIn: true,
|
|
Content: `[Service]
|
|
Environment="ETCD_DISCOVERY=http://disco.example.com/foobar"
|
|
Environment="ETCD_NAME=node001"
|
|
Environment="ETCD_PEER_BIND_ADDR=127.0.0.1:7002"
|
|
`,
|
|
}}},
|
|
},
|
|
} {
|
|
units := Etcd{tt.config}.Units()
|
|
if !reflect.DeepEqual(tt.units, units) {
|
|
t.Errorf("bad units (%q): want %#v, got %#v", tt.config, tt.units, units)
|
|
}
|
|
}
|
|
}
|