@@ -68,4 +68,57 @@ func touch(t *testing.T, path string) {
6868 if err := os .WriteFile (path , nil , 0o644 ); err != nil {
6969 t .Fatalf ("touch %s: %v" , path , err )
7070 }
71+ }
72+
73+ func TestDetect_DockerCompose_legacy_yml (t * testing.T ) {
74+ dir := t .TempDir ()
75+ touch (t , filepath .Join (dir , "docker-compose.yml" ))
76+ stack := Detect (dir )
77+ if ! stack .DockerCompose {
78+ t .Error ("expected DockerCompose=true for docker-compose.yml" )
79+ }
80+ if ! stack .Docker {
81+ t .Error ("expected Docker=true when DockerCompose is true" )
82+ }
83+ }
84+
85+ func TestDetect_DockerCompose_legacy_yaml (t * testing.T ) {
86+ dir := t .TempDir ()
87+ touch (t , filepath .Join (dir , "docker-compose.yaml" ))
88+ stack := Detect (dir )
89+ if ! stack .DockerCompose {
90+ t .Error ("expected DockerCompose=true for docker-compose.yaml" )
91+ }
92+ }
93+
94+ func TestDetect_DockerCompose_compose_yml (t * testing.T ) {
95+ dir := t .TempDir ()
96+ touch (t , filepath .Join (dir , "compose.yml" ))
97+ stack := Detect (dir )
98+ if ! stack .DockerCompose {
99+ t .Error ("expected DockerCompose=true for compose.yml" )
100+ }
101+ if ! stack .Docker {
102+ t .Error ("expected Docker=true when DockerCompose is true" )
103+ }
104+ }
105+
106+ func TestDetect_DockerCompose_compose_yaml (t * testing.T ) {
107+ dir := t .TempDir ()
108+ touch (t , filepath .Join (dir , "compose.yaml" ))
109+ stack := Detect (dir )
110+ if ! stack .DockerCompose {
111+ t .Error ("expected DockerCompose=true for compose.yaml" )
112+ }
113+ if ! stack .Docker {
114+ t .Error ("expected Docker=true when DockerCompose is true" )
115+ }
116+ }
117+
118+ func TestDetect_DockerCompose_false_when_absent (t * testing.T ) {
119+ dir := t .TempDir ()
120+ stack := Detect (dir )
121+ if stack .DockerCompose {
122+ t .Error ("expected DockerCompose=false when no compose file present" )
123+ }
71124}
0 commit comments