Skip to content

Commit f6beca6

Browse files
committed
Fixing report B
1 parent d353545 commit f6beca6

5 files changed

Lines changed: 68 additions & 5 deletions

File tree

cmd/contacts.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,4 +390,3 @@ func getStringValue(v interface{}) string {
390390
return fmt.Sprintf("%v", val)
391391
}
392392
}
393-

cmd/root.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,3 @@ func initConfig() {
5656
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
5757
}
5858
}
59-

cmd/version.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ var versionCmd = &cobra.Command{
3131
func init() {
3232
rootCmd.AddCommand(versionCmd)
3333
}
34-

internal/hubspot/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (c *Client) SearchContacts(query string, limit int) (*ContactResponse, erro
217217

218218
// Parse query - if it contains "=", treat as property=value, otherwise search in common fields
219219
var filterGroups []map[string]interface{}
220-
220+
221221
if strings.Contains(query, "=") {
222222
// Property-based search
223223
parts := strings.SplitN(query, "=", 2)
@@ -287,4 +287,3 @@ func (c *Client) ListProperties() ([]Property, error) {
287287

288288
return propsResp.Results, nil
289289
}
290-

internal/hubspot/client_test.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package hubspot
2+
3+
import (
4+
"net/http"
5+
"net/http/httptest"
6+
"testing"
7+
)
8+
9+
func TestNewClient(t *testing.T) {
10+
apiKey := "test-api-key"
11+
client := NewClient(apiKey)
12+
13+
if client == nil {
14+
t.Fatal("NewClient returned nil")
15+
}
16+
17+
if client.apiKey != apiKey {
18+
t.Errorf("Expected API key %s, got %s", apiKey, client.apiKey)
19+
}
20+
21+
if client.baseURL != baseURL {
22+
t.Errorf("Expected base URL %s, got %s", baseURL, client.baseURL)
23+
}
24+
25+
if client.client == nil {
26+
t.Fatal("HTTP client is nil")
27+
}
28+
}
29+
30+
func TestClient_doRequest(t *testing.T) {
31+
// Create a test server
32+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
33+
if r.Header.Get("Authorization") != "Bearer test-api-key" {
34+
t.Error("Missing or incorrect Authorization header")
35+
}
36+
w.WriteHeader(http.StatusOK)
37+
w.Write([]byte(`{"test": "data"}`))
38+
}))
39+
defer server.Close()
40+
41+
client := NewClient("test-api-key")
42+
client.baseURL = server.URL
43+
44+
_, err := client.doRequest("GET", "/test", nil)
45+
if err != nil {
46+
t.Errorf("doRequest failed: %v", err)
47+
}
48+
}
49+
50+
func TestContact_String(t *testing.T) {
51+
contact := Contact{
52+
ID: "123",
53+
Properties: map[string]interface{}{
54+
"email": "test@example.com",
55+
},
56+
}
57+
58+
if contact.ID != "123" {
59+
t.Errorf("Expected ID 123, got %s", contact.ID)
60+
}
61+
62+
email, ok := contact.Properties["email"].(string)
63+
if !ok || email != "test@example.com" {
64+
t.Errorf("Expected email test@example.com, got %v", contact.Properties["email"])
65+
}
66+
}
67+

0 commit comments

Comments
 (0)