refactor: update tool imports to use shared module#13
Conversation
- Refactor cfl to embed shared client and re-export shared config helpers - Refactor jtk to embed shared client and re-export shared errors - Update shared client to handle absolute URLs for jtk's URL building pattern - Remove duplicated code in favor of shared implementations - Update all tests to use new API patterns Closes #3 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Test Coverage Assessment for PR #13SummaryThis refactoring PR has good overall test coverage. The existing tests adequately verify that the refactored code maintains the same behavior as before. However, I identified one notable gap that should be addressed. What's Well TestedShared Client (
cfl API Client (
jtk API Client (
Error Re-exports (
Config (
Gap Identified: Absolute URL HandlingLocation: // Check if path is an absolute URL
if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") {
url = path
}This is new functionality added in this PR - the client can now accept absolute URLs that bypass Why it matters: This feature is used by the Jira client which constructs full URLs like RecommendationAdd a test case to t.Run("absolute URL bypasses BaseURL", func(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/external/api/test" {
t.Errorf("Path = %v, want /external/api/test", r.URL.Path)
}
w.WriteHeader(http.StatusOK)
}))
defer server.Close()
// Create client with a different base URL
c := New("https://should-not-be-used.com", "user@example.com", "token", nil)
// Pass absolute URL - should go directly to server, not prepend BaseURL
_, err := c.Get(context.Background(), server.URL+"/external/api/test")
if err != nil {
t.Fatalf("Get() with absolute URL error = %v", err)
}
})VerdictCoverage is sufficient for merging - this is a refactoring with minimal new behavior, and existing tests provide good confidence in backward compatibility. The missing test for absolute URL handling is a minor gap that can be addressed in a follow-up PR. The test updates in this PR are well-structured:
|
Addresses TDD assessment feedback - verifies that the shared client correctly handles absolute URLs by using them directly instead of prepending BaseURL. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
atlassian-gomodule instead of duplicated internal implementationsChanges
shared/client
Do()method to detect and handle absolute URLs (enables jtk's existing pattern)tools/cfl
api/client.go: Embed*client.Clientand add accessor methods (GetHTTPClient, GetBaseURL, GetAuthHeader)api/attachments.go: Use accessor methods instead of direct field accessinternal/config/config.go: Use sharedconfig.GetEnvWithFallbacktools/jtk
api/client.go: Embed*client.Clientwhile keeping Jira-specific URL fields (BaseURL, AgileURL)api/errors.go: Re-export shared errors while keeping Jira-specific errors (ErrIssueKeyRequired)api.New(api.ClientConfig{...})constructorTest plan
make testpasses for all modulesmake lintpasses for all modulesCloses #3
🤖 Generated with Claude Code