- 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>
80 lines
2.0 KiB
Go
80 lines
2.0 KiB
Go
package postgres
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/orchard9/rdev/internal/domain"
|
|
)
|
|
|
|
// Helper function conversion tests
|
|
|
|
func TestScopesToStrings(t *testing.T) {
|
|
scopes := []domain.Scope{domain.ScopeProjectsRead, domain.ScopeAdmin}
|
|
strings := scopesToStrings(scopes)
|
|
|
|
if len(strings) != 2 {
|
|
t.Fatalf("Length = %d, want 2", len(strings))
|
|
}
|
|
if strings[0] != "projects:read" {
|
|
t.Errorf("strings[0] = %q, want %q", strings[0], "projects:read")
|
|
}
|
|
if strings[1] != "admin" {
|
|
t.Errorf("strings[1] = %q, want %q", strings[1], "admin")
|
|
}
|
|
}
|
|
|
|
func TestScopesFromStrings(t *testing.T) {
|
|
strings := []string{"projects:read", "keys:write"}
|
|
scopes := scopesFromStrings(strings)
|
|
|
|
if len(scopes) != 2 {
|
|
t.Fatalf("Length = %d, want 2", len(scopes))
|
|
}
|
|
if scopes[0] != domain.ScopeProjectsRead {
|
|
t.Errorf("scopes[0] = %q, want %q", scopes[0], domain.ScopeProjectsRead)
|
|
}
|
|
if scopes[1] != domain.ScopeKeysWrite {
|
|
t.Errorf("scopes[1] = %q, want %q", scopes[1], domain.ScopeKeysWrite)
|
|
}
|
|
}
|
|
|
|
func TestProjectIDsToStrings(t *testing.T) {
|
|
t.Run("nil input", func(t *testing.T) {
|
|
result := projectIDsToStrings(nil)
|
|
if result != nil {
|
|
t.Errorf("Expected nil, got %v", result)
|
|
}
|
|
})
|
|
|
|
t.Run("non-nil input", func(t *testing.T) {
|
|
ids := []domain.ProjectID{"proj-a", "proj-b"}
|
|
result := projectIDsToStrings(ids)
|
|
if len(result) != 2 {
|
|
t.Fatalf("Length = %d, want 2", len(result))
|
|
}
|
|
if result[0] != "proj-a" || result[1] != "proj-b" {
|
|
t.Errorf("Unexpected result: %v", result)
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestProjectIDsFromStrings(t *testing.T) {
|
|
t.Run("nil input", func(t *testing.T) {
|
|
result := projectIDsFromStrings(nil)
|
|
if result != nil {
|
|
t.Errorf("Expected nil, got %v", result)
|
|
}
|
|
})
|
|
|
|
t.Run("non-nil input", func(t *testing.T) {
|
|
strings := []string{"proj-x", "proj-y"}
|
|
result := projectIDsFromStrings(strings)
|
|
if len(result) != 2 {
|
|
t.Fatalf("Length = %d, want 2", len(result))
|
|
}
|
|
if result[0] != "proj-x" || result[1] != "proj-y" {
|
|
t.Errorf("Unexpected result: %v", result)
|
|
}
|
|
})
|
|
}
|