32 lines
859 B
Go
32 lines
859 B
Go
|
package daemon
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
service "spud/service"
|
||
|
service_definition "spud/service_definition"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
type DummyClient struct{}
|
||
|
|
||
|
func (c DummyClient) Create(d service_definition.ServiceDefinition) {}
|
||
|
func (c DummyClient) Stop(d string) {}
|
||
|
|
||
|
func TestDaemonDefaultsToPodmanClient(t *testing.T) {
|
||
|
d := NewDaemon("host", 0, nil)
|
||
|
|
||
|
clientType := reflect.TypeOf(d.Services).String()
|
||
|
if clientType != reflect.TypeOf(&service.PodmanServiceClient{}).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)
|
||
|
}
|
||
|
}
|