This commit is contained in:
2026-05-13 20:40:14 +08:00
parent bd13c842a8
commit c8a75ef2d5
17 changed files with 920 additions and 93 deletions

View File

@@ -44,6 +44,31 @@ func TestListOrgSkillsFiltersReposWithoutSkillMD(t *testing.T) {
}
}
func TestListOrgSkillsNormalizesLoopbackCloneURLToConfiguredBaseURL(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/api/v1/orgs/skills/repos", func(w http.ResponseWriter, r *http.Request) {
_ = json.NewEncoder(w).Encode([]apiRepo{
{Name: "good", FullName: "skills/good", CloneURL: "http://localhost:3000/skills/good.git", DefaultBranch: "main"},
})
})
mux.HandleFunc("/api/v1/repos/skills/good/contents/SKILL.md", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
server := httptest.NewServer(mux)
defer server.Close()
client := NewClient(server.URL, Auth{Type: AuthPassword, Username: "alice", Secret: "secret"})
repos, err := client.ListOrgSkills(context.Background(), "skills")
if err != nil {
t.Fatalf("ListOrgSkills returned error: %v", err)
}
want := server.URL + "/skills/good.git"
if repos[0].CloneURL != want {
t.Fatalf("CloneURL = %q, want %q", repos[0].CloneURL, want)
}
}
func TestListOrgSkillsUsesTokenAuth(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/api/v1/orgs/skills/repos", func(w http.ResponseWriter, r *http.Request) {