Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist/
.env
.env.local
/devcheck
.DS_Store
4 changes: 3 additions & 1 deletion internal/detector/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func Detect(dir string) DetectedStack {
stack.Gradle = fileExists(filepath.Join(dir, "build.gradle"))
stack.Java = stack.Maven || stack.Gradle
stack.DockerCompose = fileExists(filepath.Join(dir, "docker-compose.yml")) ||
fileExists(filepath.Join(dir, "docker-compose.yaml"))
fileExists(filepath.Join(dir, "docker-compose.yaml")) ||
fileExists(filepath.Join(dir, "compose.yml")) ||
fileExists(filepath.Join(dir, "compose.yaml"))
stack.Docker = fileExists(filepath.Join(dir, "Dockerfile")) || stack.DockerCompose

dbURL := os.Getenv("DATABASE_URL")
Expand Down
53 changes: 53 additions & 0 deletions internal/detector/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,57 @@ func touch(t *testing.T, path string) {
if err := os.WriteFile(path, nil, 0o644); err != nil {
t.Fatalf("touch %s: %v", path, err)
}
}

func TestDetect_DockerCompose_legacy_yml(t *testing.T) {
dir := t.TempDir()
touch(t, filepath.Join(dir, "docker-compose.yml"))
stack := Detect(dir)
if !stack.DockerCompose {
t.Error("expected DockerCompose=true for docker-compose.yml")
}
if !stack.Docker {
t.Error("expected Docker=true when DockerCompose is true")
}
}

func TestDetect_DockerCompose_legacy_yaml(t *testing.T) {
dir := t.TempDir()
touch(t, filepath.Join(dir, "docker-compose.yaml"))
stack := Detect(dir)
if !stack.DockerCompose {
t.Error("expected DockerCompose=true for docker-compose.yaml")
}
}

func TestDetect_DockerCompose_compose_yml(t *testing.T) {
dir := t.TempDir()
touch(t, filepath.Join(dir, "compose.yml"))
stack := Detect(dir)
if !stack.DockerCompose {
t.Error("expected DockerCompose=true for compose.yml")
}
if !stack.Docker {
t.Error("expected Docker=true when DockerCompose is true")
}
}

func TestDetect_DockerCompose_compose_yaml(t *testing.T) {
dir := t.TempDir()
touch(t, filepath.Join(dir, "compose.yaml"))
stack := Detect(dir)
if !stack.DockerCompose {
t.Error("expected DockerCompose=true for compose.yaml")
}
if !stack.Docker {
t.Error("expected Docker=true when DockerCompose is true")
}
}

func TestDetect_DockerCompose_false_when_absent(t *testing.T) {
dir := t.TempDir()
stack := Detect(dir)
if stack.DockerCompose {
t.Error("expected DockerCompose=false when no compose file present")
}
}
Loading