- Add ListPipelines/GetPipeline to CIProvider port with Woodpecker adapter
- Add DNS alias endpoints: GET/POST/DELETE /projects/{id}/domains
- Implement worker executor daemon, build executor, and git operations
- Add build service, worker service, and build audit tracking
- Add worker registry with PostgreSQL adapter and migration
- Add multi-provider code agent interface (Claude Code + OpenCode)
- Add create-and-build combo endpoint
- Update landing-page cookbook to reflect all gaps closed
- Fix tech debt: unified validation, auth scopes, error wrapping, slog patterns
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
99 lines
2.8 KiB
Go
99 lines
2.8 KiB
Go
package handlers
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
func TestProjectsHandler_RunClaude_InvalidJSON(t *testing.T) {
|
|
h := &ProjectsHandler{streams: newStreamManager()}
|
|
r := chi.NewRouter()
|
|
h.Mount(r)
|
|
|
|
req := httptest.NewRequest("POST", "/projects/myapp/claude", bytes.NewReader([]byte("not json")))
|
|
rec := httptest.NewRecorder()
|
|
r.ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusBadRequest {
|
|
t.Errorf("status = %d, want %d", rec.Code, http.StatusBadRequest)
|
|
}
|
|
}
|
|
|
|
func TestProjectsHandler_RunClaude_NoServiceConfigured(t *testing.T) {
|
|
h := &ProjectsHandler{streams: newStreamManager()}
|
|
r := chi.NewRouter()
|
|
h.Mount(r)
|
|
|
|
body, _ := json.Marshal(ClaudeRequest{Prompt: "hello"})
|
|
req := httptest.NewRequest("POST", "/projects/myapp/claude", bytes.NewReader(body))
|
|
rec := httptest.NewRecorder()
|
|
r.ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusInternalServerError {
|
|
t.Errorf("status = %d, want %d", rec.Code, http.StatusInternalServerError)
|
|
}
|
|
}
|
|
|
|
func TestProjectsHandler_RunShell_InvalidJSON(t *testing.T) {
|
|
h := &ProjectsHandler{streams: newStreamManager()}
|
|
r := chi.NewRouter()
|
|
h.Mount(r)
|
|
|
|
req := httptest.NewRequest("POST", "/projects/myapp/shell", bytes.NewReader([]byte("not json")))
|
|
rec := httptest.NewRecorder()
|
|
r.ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusBadRequest {
|
|
t.Errorf("status = %d, want %d", rec.Code, http.StatusBadRequest)
|
|
}
|
|
}
|
|
|
|
func TestProjectsHandler_RunShell_NoServiceConfigured(t *testing.T) {
|
|
h := &ProjectsHandler{streams: newStreamManager()}
|
|
r := chi.NewRouter()
|
|
h.Mount(r)
|
|
|
|
body, _ := json.Marshal(ShellRequest{Command: "ls"})
|
|
req := httptest.NewRequest("POST", "/projects/myapp/shell", bytes.NewReader(body))
|
|
rec := httptest.NewRecorder()
|
|
r.ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusInternalServerError {
|
|
t.Errorf("status = %d, want %d", rec.Code, http.StatusInternalServerError)
|
|
}
|
|
}
|
|
|
|
func TestProjectsHandler_RunGit_InvalidJSON(t *testing.T) {
|
|
h := &ProjectsHandler{streams: newStreamManager()}
|
|
r := chi.NewRouter()
|
|
h.Mount(r)
|
|
|
|
req := httptest.NewRequest("POST", "/projects/myapp/git", bytes.NewReader([]byte("not json")))
|
|
rec := httptest.NewRecorder()
|
|
r.ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusBadRequest {
|
|
t.Errorf("status = %d, want %d", rec.Code, http.StatusBadRequest)
|
|
}
|
|
}
|
|
|
|
func TestProjectsHandler_RunGit_NoServiceConfigured(t *testing.T) {
|
|
h := &ProjectsHandler{streams: newStreamManager()}
|
|
r := chi.NewRouter()
|
|
h.Mount(r)
|
|
|
|
body, _ := json.Marshal(GitRequest{Args: []string{"status"}})
|
|
req := httptest.NewRequest("POST", "/projects/myapp/git", bytes.NewReader(body))
|
|
rec := httptest.NewRecorder()
|
|
r.ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusInternalServerError {
|
|
t.Errorf("status = %d, want %d", rec.Code, http.StatusInternalServerError)
|
|
}
|
|
}
|