You've already forked agentic-coding-workflow
feat(workspace): add GET /branches endpoint
This commit is contained in:
@@ -49,7 +49,7 @@ func (f *fakeWS) GetCredentialMeta(_ context.Context, _ Caller, _ uuid.UUID) (*C
|
||||
}
|
||||
|
||||
func (f *fakeWS) ListBranches(_ context.Context, _ Caller, _ uuid.UUID) ([]string, error) {
|
||||
return nil, nil
|
||||
return []string{"main", "develop"}, nil
|
||||
}
|
||||
|
||||
// fakeResolver 把固定 token 解码为 uuid(沿 internal/project handler_test.go 模式)。
|
||||
@@ -86,3 +86,26 @@ func TestHandler_CreateWorkspace_Smoke(t *testing.T) {
|
||||
r.ServeHTTP(w, req)
|
||||
require.Equal(t, http.StatusCreated, w.Code)
|
||||
}
|
||||
|
||||
func TestHandler_ListBranches_Smoke(t *testing.T) {
|
||||
t.Parallel()
|
||||
ws := &fakeWS{}
|
||||
uid := uuid.New()
|
||||
tok := "tok-branches"
|
||||
resolver := &fakeResolver{valid: map[string]uuid.UUID{tok: uid}}
|
||||
h := NewHandler(ws, nil, nil, resolver, fakeAdmin{})
|
||||
r := chi.NewRouter()
|
||||
r.Use(middleware.RequestID)
|
||||
h.Mount(r)
|
||||
|
||||
wsID := uuid.New()
|
||||
req := httptest.NewRequest("GET", "/api/v1/workspaces/"+wsID.String()+"/branches", nil)
|
||||
req.Header.Set("Authorization", "Bearer "+tok)
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
require.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
var resp branchListResp
|
||||
require.NoError(t, json.NewDecoder(w.Body).Decode(&resp))
|
||||
require.Equal(t, []string{"main", "develop"}, resp.Branches)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user