spud/daemon/daemon_test.go

32 lines
898 B
Go
Raw Permalink Normal View History

package daemon
import (
"reflect"
service "spud/service"
service_definition "spud/service_definition"
"testing"
)
type DummyClient struct{}
func (c DummyClient) Create(d service_definition.ServiceDefinition) error { return nil }
func (c DummyClient) Stop(d string) error { return nil }
func TestDaemonDefaultsToPodmanClient(t *testing.T) {
d := NewDaemon("host", 0, nil)
clientType := reflect.TypeOf(d.Services).String()
if clientType != reflect.TypeOf(service.NewPodmanServiceManager()).String() {
t.Errorf("Expected podman client, got %s instead.", clientType)
}
}
func TestDaemonUsesInjectedClientIfProvided(t *testing.T) {
d := NewDaemon("host", 0, DummyClient{})
clientType := reflect.TypeOf(d.Services).String()
if clientType != reflect.TypeOf(DummyClient{}).String() {
t.Errorf("Expected dummy client, got %s instead.", clientType)
}
}