summaryrefslogtreecommitdiff
path: root/internal/api/trello_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/trello_test.go')
-rw-r--r--internal/api/trello_test.go35
1 files changed, 11 insertions, 24 deletions
diff --git a/internal/api/trello_test.go b/internal/api/trello_test.go
index b43b55e..7433ff0 100644
--- a/internal/api/trello_test.go
+++ b/internal/api/trello_test.go
@@ -12,6 +12,13 @@ import (
"time"
)
+// newTestTrelloClient creates a TrelloClient for testing with custom base URL
+func newTestTrelloClient(baseURL, apiKey, token string) *TrelloClient {
+ client := NewTrelloClient(apiKey, token)
+ client.BaseClient.BaseURL = baseURL
+ return client
+}
+
func TestTrelloClient_CreateCard(t *testing.T) {
// Mock server
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -65,12 +72,7 @@ func TestTrelloClient_CreateCard(t *testing.T) {
defer server.Close()
// Create client with mock server URL
- client := &TrelloClient{
- apiKey: "test-key",
- token: "test-token",
- baseURL: server.URL,
- httpClient: &http.Client{},
- }
+ client := newTestTrelloClient(server.URL, "test-key", "test-token")
// Test CreateCard
ctx := context.Background()
@@ -125,12 +127,7 @@ func TestTrelloClient_CreateCard_WithDueDate(t *testing.T) {
defer server.Close()
// Create client
- client := &TrelloClient{
- apiKey: "test-key",
- token: "test-token",
- baseURL: server.URL,
- httpClient: &http.Client{},
- }
+ client := newTestTrelloClient(server.URL, "test-key", "test-token")
// Test CreateCard with due date
ctx := context.Background()
@@ -184,12 +181,7 @@ func TestTrelloClient_UpdateCard(t *testing.T) {
defer server.Close()
// Create client
- client := &TrelloClient{
- apiKey: "test-key",
- token: "test-token",
- baseURL: server.URL,
- httpClient: &http.Client{},
- }
+ client := newTestTrelloClient(server.URL, "test-key", "test-token")
// Test UpdateCard
ctx := context.Background()
@@ -214,12 +206,7 @@ func TestTrelloClient_UpdateCard_Error(t *testing.T) {
defer server.Close()
// Create client
- client := &TrelloClient{
- apiKey: "test-key",
- token: "test-token",
- baseURL: server.URL,
- httpClient: &http.Client{},
- }
+ client := newTestTrelloClient(server.URL, "test-key", "test-token")
// Test UpdateCard with error
ctx := context.Background()