Skip to content

Commit 7f01a85

Browse files
authored
Merge pull request #1212 from wakatime/feature/heartbeat-response-id
Parse results with ID from API
2 parents 97465bf + 557c4c3 commit 7f01a85

22 files changed

+134
-924
lines changed

cmd/handler/handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestHandlerNew(t *testing.T) {
6363
})
6464
require.NoError(t, err)
6565

66-
assert.Len(t, res, 1)
66+
require.Len(t, res, 1)
6767
assert.Equal(t, res[0].Heartbeat.APIKey, "00000000-0000-4000-8000-000000000002")
6868
}
6969

cmd/handler/option_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ func TestWithFormatting(t *testing.T) {
2424
assert.Len(t, res, 0)
2525
}
2626

27+
func TestWithCategoryDetection(t *testing.T) {
28+
opt := handler.WithCategoryDetection()
29+
30+
chain := heartbeat.NewHandle(noopMock{})
31+
hdl := opt(params.Params{})(chain)
32+
33+
res, err := hdl(context.Background(), nil)
34+
require.NoError(t, err)
35+
36+
assert.Len(t, res, 0)
37+
}
38+
2739
func TestWithEntityModifier(t *testing.T) {
2840
opt := handler.WithEntityModifier()
2941

cmd/heartbeat/testdata/api_heartbeats_response.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,7 @@
33
[
44
{
55
"data": {
6-
"branch": "heartbeat",
7-
"category": "coding",
8-
"created_at": "2020-04-14T21:27:15Z",
9-
"cursorpos": 12,
10-
"dependencies": ["dep1", "dep2"],
11-
"entity": "/tmp/main.go",
12-
"id": "845a922e-9e65-4775-bd68-bb3196d2e06a",
13-
"is_write": true,
14-
"language": "Go",
15-
"lineno": 42,
16-
"lines": 100,
17-
"machine_name_id": null,
18-
"project": "wakatime-cli",
19-
"type": "file",
20-
"time": 1585598059.0,
21-
"user_agent_id": null,
22-
"user_agent": "wakatime/13.0.6",
23-
"user_id": "9c4a41c0-eb11-4cf5-84b8-d5b7f5e91bea"
6+
"id": "H3C4D5E6-F7G8-9012-3456-789ABCDEF123"
247
}
258
},
269
201

0 commit comments

Comments
 (0)