diff --git a/internal/deps/composition.go b/internal/deps/composition.go index 2563dda..f4ebbd6 100644 --- a/internal/deps/composition.go +++ b/internal/deps/composition.go @@ -192,10 +192,9 @@ func (comp Composition) RecursiveDepsOf(s string) (newcomp *Composition, err err for len(todo) > 0 { for serviceName := range todo { - service, ok := comp.Services[serviceName] - + _, ok := comp.Services[serviceName] if !ok { - comp.AddService(serviceName, NewService(service.Deployable)) + return nil, fmt.Errorf("application %s does not exist", serviceName) } newcomp.Services[serviceName] = comp.Services[serviceName] diff --git a/internal/deps/composition_test.go b/internal/deps/composition_test.go index 4790e69..7476a7a 100644 --- a/internal/deps/composition_test.go +++ b/internal/deps/composition_test.go @@ -85,17 +85,6 @@ func TestRecursiveDepsOf(t *testing.T) { } } -func TestRecursiveDepsOfWithListOfServices(t *testing.T) { - comp := newTestComp() - - got, _ := comp.RecursiveDepsOf("fourth-service,first-service") - - _, ok := got.Services["fifth-service"] - if !ok { - t.Error("expected to have 'fifth-service' in composition") - } -} - func TestRecursiveDepsOfWithListOfServicesAndBlank(t *testing.T) { comp := newTestComp() got, _ := comp.RecursiveDepsOf("fifth-service, fourth-service") @@ -215,3 +204,12 @@ func TestDeployOrderWithUndeployables(t *testing.T) { cmpSlice(t, []string{"d"}, order) } + +func TestRecursiveDepsOfFailsIfUnknownAppIsSpecified(t *testing.T) { + comp := NewComposition() + _, err := comp.RecursiveDepsOf("xyz") + expectedErrStr := "application xyz does not exist" + if err == nil || err.Error() != expectedErrStr { + t.Fatalf("expected err with msg: %q, got: %v", expectedErrStr, err) + } +}