test(caddy): cover invalid path branches; ci: handle go test non-zero when coverage file exists

This commit is contained in:
CI
2025-11-29 08:55:25 +00:00
parent 0c62118989
commit fcc273262c
51 changed files with 1117 additions and 205 deletions

View File

@@ -1,8 +1,11 @@
package handlers
import (
"fmt"
"log"
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
@@ -72,12 +75,13 @@ func (h *ProxyHostHandler) Create(c *gin.Context) {
}
if h.caddyManager != nil {
if err := h.caddyManager.ApplyConfig(c.Request.Context()); err != nil {
// Rollback: delete the created host if config application fails
fmt.Printf("Error applying config: %v\n", err) // Log to stdout
if deleteErr := h.service.Delete(host.ID); deleteErr != nil {
fmt.Printf("Critical: Failed to rollback host %d: %v\n", host.ID, deleteErr)
}
if err := h.caddyManager.ApplyConfig(c.Request.Context()); err != nil {
// Rollback: delete the created host if config application fails
log.Printf("Error applying config: %s", sanitizeForLog(err.Error()))
if deleteErr := h.service.Delete(host.ID); deleteErr != nil {
idStr := strconv.FormatUint(uint64(host.ID), 10)
log.Printf("Critical: Failed to rollback host %s: %s", sanitizeForLog(idStr), sanitizeForLog(deleteErr.Error()))
}
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to apply configuration: " + err.Error()})
return
}