Skip to content

Commit eead56e

Browse files
authored
Fix/docker compose (#43)
2 parents 22e4901 + 89ce990 commit eead56e

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ dist/
55
.env
66
.env.local
77
/devcheck
8+
.DS_Store

internal/detector/detector.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ func Detect(dir string) DetectedStack {
4646
stack.Gradle = fileExists(filepath.Join(dir, "build.gradle"))
4747
stack.Java = stack.Maven || stack.Gradle
4848
stack.DockerCompose = fileExists(filepath.Join(dir, "docker-compose.yml")) ||
49-
fileExists(filepath.Join(dir, "docker-compose.yaml"))
49+
fileExists(filepath.Join(dir, "docker-compose.yaml")) ||
50+
fileExists(filepath.Join(dir, "compose.yml")) ||
51+
fileExists(filepath.Join(dir, "compose.yaml"))
5052
stack.Docker = fileExists(filepath.Join(dir, "Dockerfile")) || stack.DockerCompose
5153

5254
dbURL := os.Getenv("DATABASE_URL")

internal/detector/detector_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)