feat: funciones infra — Docker, deploy, build y health check
Funciones impuras para gestión de contenedores: docker_build_image, docker_compose_up/down, docker_volume_create/list/remove, generate_dockerfile, write_dockerfile, go_build_binary, health_check_http, deploy_app y stop_app. Todas con tests unitarios donde aplica. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package infra
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDockerVolumeCreate(t *testing.T) {
|
||||
t.Run("crea volume y retorna nombre", func(t *testing.T) {
|
||||
name := "fn-registry-test-vol-create"
|
||||
|
||||
got, err := DockerVolumeCreate(name)
|
||||
if err != nil {
|
||||
t.Skipf("docker no disponible: %v", err)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(got) != name {
|
||||
t.Errorf("got %q, want %q", got, name)
|
||||
}
|
||||
|
||||
// Limpiar
|
||||
_ = DockerVolumeRemove(name, false)
|
||||
})
|
||||
|
||||
t.Run("idempotente si el volume ya existe", func(t *testing.T) {
|
||||
name := "fn-registry-test-vol-idempotent"
|
||||
|
||||
first, err := DockerVolumeCreate(name)
|
||||
if err != nil {
|
||||
t.Skipf("docker no disponible: %v", err)
|
||||
}
|
||||
defer DockerVolumeRemove(name, false) //nolint
|
||||
|
||||
second, err := DockerVolumeCreate(name)
|
||||
if err != nil {
|
||||
t.Errorf("segunda llamada fallo: %v", err)
|
||||
}
|
||||
if first != second {
|
||||
t.Errorf("nombres distintos: %q vs %q", first, second)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user