|
|
@@ -19,6 +19,7 @@ package compose
|
|
|
import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
+ "strings"
|
|
|
"testing"
|
|
|
|
|
|
"github.com/compose-spec/compose-go/types"
|
|
|
@@ -184,3 +185,21 @@ func TestServiceLinks(t *testing.T) {
|
|
|
assert.Equal(t, links[2], "testProject-web-1:testProject-web-1")
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+func TestWaitDependencies(t *testing.T) {
|
|
|
+ mockCtrl := gomock.NewController(t)
|
|
|
+ defer mockCtrl.Finish()
|
|
|
+ api := mocks.NewMockAPIClient(mockCtrl)
|
|
|
+ tested.apiClient = api
|
|
|
+
|
|
|
+ t.Run("should skip dependencies with scale 0", func(t *testing.T) {
|
|
|
+ dbService := types.ServiceConfig{Name: "db", Scale: 0}
|
|
|
+ redisService := types.ServiceConfig{Name: "redis", Scale: 0}
|
|
|
+ project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{dbService, redisService}}
|
|
|
+ dependencies := types.DependsOnConfig{
|
|
|
+ "db": {Condition: ServiceConditionRunningOrHealthy},
|
|
|
+ "redis": {Condition: ServiceConditionRunningOrHealthy},
|
|
|
+ }
|
|
|
+ assert.NilError(t, tested.waitDependencies(context.Background(), &project, dependencies))
|
|
|
+ })
|
|
|
+}
|