@@ -2246,7 +2246,7 @@ func TestLoadLegacyBoolean(t *testing.T) {
22462246name: load-legacy-boolean
22472247services:
22482248 test:
2249- init: yes # used to be a valid YAML bool, removed in YAML 1.2
2249+ init: yes # used to be a valid YAML bool, removed in YAML 1.2
22502250` )
22512251 assert .NilError (t , err )
22522252 assert .Check (t , * actual .Services [0 ].Init )
@@ -2276,7 +2276,7 @@ services:
22762276 test:
22772277 build:
22782278 context: .
2279- ssh:
2279+ ssh:
22802280 key1: value1
22812281` )
22822282 assert .NilError (t , err )
@@ -2294,7 +2294,7 @@ services:
22942294 test:
22952295 build:
22962296 context: .
2297- ssh:
2297+ ssh:
22982298 - key1=value1
22992299 - key2=value2
23002300` )
@@ -2642,7 +2642,7 @@ include:
26422642 env_file: ./testdata/subdir/extra.env
26432643 - path: ./testdata/compose-include.yaml
26442644 env_file: ./testdata/subdir/extra.env
2645-
2645+
26462646
26472647services:
26482648 bar:
@@ -2767,7 +2767,7 @@ services:
27672767func TestLoadWithNestedResources (t * testing.T ) {
27682768 config := buildConfigDetails (`
27692769name: test-nested-resources
2770- include:
2770+ include:
27712771 - remote:nested/compose.yaml
27722772` , nil )
27732773 _ , err := LoadWithContext (context .Background (), config , func (options * Options ) {
@@ -2808,7 +2808,7 @@ name: load-multi-docs
28082808services:
28092809 test:
28102810 image: nginx:latest
2811- ---
2811+ ---
28122812services:
28132813 test:
28142814 image: nginx:override
@@ -2826,7 +2826,7 @@ services:
28262826 image: example/webapp
28272827 build: ./webapp
28282828 develop:
2829- watch:
2829+ watch:
28302830 # sync static content
28312831 - path: ./webapp/html
28322832 action: sync
@@ -2838,7 +2838,7 @@ services:
28382838 image: example/backend
28392839 build: ./backend
28402840 develop:
2841- watch:
2841+ watch:
28422842 # rebuild image and recreate service
28432843 - path: ./backend/src
28442844 action: rebuild
@@ -2887,3 +2887,25 @@ services:
28872887 },
28882888 })
28892889}
2890+
2891+ func TestBadServiceConfig (t * testing.T ) {
2892+ yaml := `name: scratch
2893+ services:
2894+ redis:
2895+ image: redis:6.2.6-alpine
2896+ network_mode: bridge
2897+ networks:
2898+ gratheon: null
2899+ networks:
2900+ gratheon:
2901+ name: scratch_gratheon
2902+ `
2903+ _ , err := LoadWithContext (context .Background (), types.ConfigDetails {
2904+ ConfigFiles : []types.ConfigFile {
2905+ {
2906+ Content : []byte (yaml ),
2907+ },
2908+ },
2909+ })
2910+ assert .ErrorContains (t , err , "service redis declares mutually exclusive `network_mode` and `networks`" )
2911+ }
0 commit comments