@@ -27,128 +27,87 @@ func Test_suggestRemoteBuild(t *testing.T) {
2727 }
2828
2929 tests := []struct {
30- name string
31- services []* ServiceConfig
32- toolErr * tools.MissingToolErrors
33- serviceFilterFn ServiceFilterPredicate
34- wantSuggestion bool
35- wantContains string
30+ name string
31+ svcTools []svcToolInfo
32+ toolErr * tools.MissingToolErrors
33+ wantSuggestion bool
34+ wantContains string
3635 }{
3736 {
38- name : "ContainerApp_without_remoteBuild_suggests " ,
39- services : []* ServiceConfig {
40- {Name : "api" , Host : ContainerAppTarget },
37+ name : "Service_needing_Docker_suggests " ,
38+ svcTools : []svcToolInfo {
39+ {svc : & ServiceConfig { Name : "api" }, needsDocker : true },
4140 },
4241 toolErr : dockerMissing ,
4342 wantSuggestion : true ,
4443 wantContains : "api" ,
4544 },
46- {
47- name : "AKS_without_remoteBuild_suggests" ,
48- services : []* ServiceConfig {
49- {Name : "worker" , Host : AksTarget },
50- },
51- toolErr : dockerMissing ,
52- wantSuggestion : true ,
53- wantContains : "worker" ,
54- },
5545 {
5646 name : "Multiple_services_lists_all" ,
57- services : []* ServiceConfig {
58- {Name : "api" , Host : ContainerAppTarget },
59- {Name : "web" , Host : ContainerAppTarget },
47+ svcTools : []svcToolInfo {
48+ {svc : & ServiceConfig { Name : "api" }, needsDocker : true },
49+ {svc : & ServiceConfig { Name : "web" }, needsDocker : true },
6050 },
6151 toolErr : dockerMissing ,
6252 wantSuggestion : true ,
6353 wantContains : "api, web" ,
6454 },
6555 {
66- name : "ContainerApp_with_remoteBuild_no_suggestion" ,
67- services : []* ServiceConfig {
68- {Name : "api" , Host : ContainerAppTarget , Docker : DockerProjectOptions {RemoteBuild : true }},
69- },
70- toolErr : dockerMissing ,
71- wantSuggestion : false ,
72- },
73- {
74- name : "AppService_no_suggestion" ,
75- services : []* ServiceConfig {
76- {Name : "web" , Host : AppServiceTarget },
56+ name : "Service_not_needing_Docker_no_suggestion" ,
57+ svcTools : []svcToolInfo {
58+ {svc : & ServiceConfig {Name : "api" }, needsDocker : false },
7759 },
7860 toolErr : dockerMissing ,
7961 wantSuggestion : false ,
8062 },
8163 {
8264 name : "Non_Docker_tool_missing_no_suggestion" ,
83- services : []* ServiceConfig {
84- {Name : "api" , Host : ContainerAppTarget },
65+ svcTools : []svcToolInfo {
66+ {svc : & ServiceConfig { Name : "api" }, needsDocker : true },
8567 },
8668 toolErr : bicepMissing ,
8769 wantSuggestion : false ,
8870 },
8971 {
90- name : "Mixed_services_only_suggests_container_targets " ,
91- services : []* ServiceConfig {
92- {Name : "api" , Host : ContainerAppTarget },
93- {Name : "web" , Host : AppServiceTarget },
94- {Name : "worker" , Host : AksTarget },
72+ name : "Mixed_services_only_Docker_ones " ,
73+ svcTools : []svcToolInfo {
74+ {svc : & ServiceConfig { Name : "api" }, needsDocker : true },
75+ {svc : & ServiceConfig { Name : "web" }, needsDocker : false },
76+ {svc : & ServiceConfig { Name : "worker" }, needsDocker : true },
9577 },
9678 toolErr : dockerMissing ,
9779 wantSuggestion : true ,
9880 wantContains : "api, worker" ,
9981 },
100- {
101- name : "Service_filter_excludes_service" ,
102- services : []* ServiceConfig {
103- {Name : "api" , Host : ContainerAppTarget },
104- {Name : "worker" , Host : ContainerAppTarget },
105- },
106- toolErr : dockerMissing ,
107- serviceFilterFn : func (svc * ServiceConfig ) bool {
108- return svc .Name == "api"
109- },
110- wantSuggestion : true ,
111- wantContains : "api" ,
112- },
113- {
114- name : "DotNet_without_Dockerfile_no_suggestion" ,
115- services : func () []* ServiceConfig {
116- useDotNet := true
117- return []* ServiceConfig {
118- {
119- Name : "api" ,
120- Host : ContainerAppTarget ,
121- Language : ServiceLanguageCsharp ,
122- useDotNetPublishForDockerBuild : & useDotNet ,
123- },
124- }
125- }(),
126- toolErr : dockerMissing ,
127- wantSuggestion : false ,
128- },
12982 {
13083 name : "Docker_not_running_suggests_start" ,
131- services : []* ServiceConfig {
132- {Name : "api" , Host : ContainerAppTarget },
84+ svcTools : []svcToolInfo {
85+ {svc : & ServiceConfig { Name : "api" }, needsDocker : true },
13386 },
13487 toolErr : dockerNotRunning ,
13588 wantSuggestion : true ,
13689 wantContains : "start your container runtime" ,
13790 },
13891 {
13992 name : "Docker_not_installed_suggests_install" ,
140- services : []* ServiceConfig {
141- {Name : "api" , Host : ContainerAppTarget },
93+ svcTools : []svcToolInfo {
94+ {svc : & ServiceConfig { Name : "api" }, needsDocker : true },
14295 },
14396 toolErr : dockerMissing ,
14497 wantSuggestion : true ,
14598 wantContains : "install Docker" ,
14699 },
100+ {
101+ name : "Empty_services_no_suggestion" ,
102+ svcTools : []svcToolInfo {},
103+ toolErr : dockerMissing ,
104+ wantSuggestion : false ,
105+ },
147106 }
148107
149108 for _ , tt := range tests {
150109 t .Run (tt .name , func (t * testing.T ) {
151- result := suggestRemoteBuild (tt .services , tt .toolErr , tt . serviceFilterFn )
110+ result := suggestRemoteBuild (tt .svcTools , tt .toolErr )
152111
153112 if ! tt .wantSuggestion {
154113 assert .Nil (t , result )
0 commit comments