Files
dingtalk-workspace-cli/test/cli_compat/testmain_test.go
T
audanye-sudo ce5e919c52 fix(market): version-code discovery path as /cli/discovery/apis/bamboo
Extract the server-list endpoint path into a single discoveryAPIPath constant and move it from /cli/discovery/apis to /cli/discovery/apis/bamboo so future version bumps touch one place.

Only the path changes: the MCP base host stays on production https://mcp.dingtalk.com and the auth / skill / doctor endpoints are untouched. The edition DiscoveryURL hook (full-URL FetchServersFromURL) is unaffected. All mock/test fixtures are updated to the new path and a CHANGELOG 1.0.34 entry is added.
2026-06-03 19:41:04 +08:00

34 lines
1.0 KiB
Go

package cli_compat_test
import (
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/app"
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/cli"
)
func TestMain(m *testing.M) {
// Set an empty catalog fixture so that EnvironmentLoader does not
// attempt live discovery (which would hang on unreachable MCP endpoints).
absFixture, _ := filepath.Abs("testdata/empty_catalog.json")
os.Setenv(cli.CatalogFixtureEnv, absFixture)
// Serve the local servers.json fixture at /cli/discovery/apis/bamboo so that
// the dynamic command generator can build CLI commands without network
// access. FetchServers calls {baseURL}/cli/discovery/apis/bamboo.
mux := http.NewServeMux()
mux.HandleFunc("/cli/discovery/apis/bamboo", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "testdata/servers.json")
})
srv := httptest.NewServer(mux)
app.SetDiscoveryBaseURL(srv.URL)
code := m.Run()
srv.Close()
os.Exit(code)
}