1
- import { expect , test } from 'vitest'
1
+ import { test } from 'vitest'
2
2
import { FakeAppState } from '../../../../../testSupport/fakes/fakeAppState'
3
3
import { FakeGithubInstallationClient } from '../../../../../testSupport/fakes/fakeGithubInstallationClient'
4
4
import {
@@ -13,6 +13,15 @@ import {
13
13
import example_personal_workflow_run from '../../../../../examples/github/personal-account/api/workflowRunEvent.json'
14
14
import example_org_workflow_run from '../../../../../examples/github/org/api/workflowRunEvent.json'
15
15
import { crawlWorkflowRunEvents } from '../../../../../../src/app/domain/github/crawler/crawlRunEvents'
16
+ import {
17
+ expectPut ,
18
+ expectPutsLength
19
+ } from '../../../../../testSupport/fakes/dynamoDB/fakeDynamoDBInterfaceExpectations'
20
+ import {
21
+ expectedPutGithubWorkflowRun ,
22
+ expectedPutGithubWorkflowRunEvent ,
23
+ expectedPutLatestGithubWorkflowRunEvent
24
+ } from '../../../../../testSupport/fakes/tableRecordExpectedWrites'
16
25
17
26
test ( 'repo-crawler-for-personal-account-installation' , async ( ) => {
18
27
// A
@@ -32,58 +41,10 @@ test('repo-crawler-for-personal-account-installation', async () => {
32
41
await crawlWorkflowRunEvents ( appState , testPersonalInstallation , testPersonalTestRepo , 10 )
33
42
34
43
// A
35
- expect ( appState . dynamoDB . puts . length ) . toEqual ( 3 )
36
- expect ( appState . dynamoDB . puts [ 0 ] ) . toEqual ( {
37
- ConditionExpression : 'attribute_not_exists(PK)' ,
38
- Item : {
39
- PK : 'ACCOUNT#162360409' ,
40
- SK : 'REPO#767679529#WORKFLOW#88508779#WORKFLOW_RUN_EVENT#UPDATED_AT#2024-03-05T18:01:40Z#RUN#8160866530#STATUS#completed' ,
41
- GSI1PK : 'ACCOUNT#162360409' ,
42
- GSI1SK : 'REPO#767679529#DATETIME#2024-03-05T18:01:40Z' ,
43
- _et : 'githubWorkflowRunEvent' ,
44
- _lastUpdated : '2024-02-02T19:00:00.000Z' ,
45
- ...testPersonalTestRepoWorkflowRun
46
- } ,
47
- TableName : 'fakeGithubRepoActivityTable'
48
- } )
49
- expect ( appState . dynamoDB . puts [ 1 ] ) . toEqual ( {
50
- ConditionExpression : 'attribute_not_exists(PK) OR #updatedAt < :newUpdatedAt' ,
51
- ExpressionAttributeNames : {
52
- '#updatedAt' : 'updatedAt'
53
- } ,
54
- ExpressionAttributeValues : {
55
- ':newUpdatedAt' : '2024-03-05T18:01:40Z'
56
- } ,
57
- Item : {
58
- PK : 'ACCOUNT#162360409' ,
59
- SK : 'REPO#767679529#WORKFLOW#88508779#WORKFLOW_RUN#RUN#8160866530' ,
60
- GSI1PK : 'ACCOUNT#162360409' ,
61
- GSI1SK : 'REPO#767679529#DATETIME#2024-03-05T18:01:40Z' ,
62
- _et : 'githubWorkflowRun' ,
63
- _lastUpdated : '2024-02-02T19:00:00.000Z' ,
64
- ...testPersonalTestRepoWorkflowRun
65
- } ,
66
- TableName : 'fakeGithubRepoActivityTable'
67
- } )
68
- expect ( appState . dynamoDB . puts [ 2 ] ) . toEqual ( {
69
- ConditionExpression : 'attribute_not_exists(PK) OR #updatedAt < :newUpdatedAt' ,
70
- ExpressionAttributeNames : {
71
- '#updatedAt' : 'updatedAt'
72
- } ,
73
- ExpressionAttributeValues : {
74
- ':newUpdatedAt' : '2024-03-05T18:01:40Z'
75
- } ,
76
- Item : {
77
- PK : 'ACCOUNT#162360409' ,
78
- SK : 'REPO#767679529#WORKFLOW#88508779' ,
79
- GSI1PK : 'ACCOUNT#162360409' ,
80
- GSI1SK : 'DATETIME#2024-03-05T18:01:40Z' ,
81
- _et : 'githubLatestWorkflowRunEvent' ,
82
- _lastUpdated : '2024-02-02T19:00:00.000Z' ,
83
- ...testPersonalTestRepoWorkflowRun
84
- } ,
85
- TableName : 'fakeGithubLatestWorkflowRunsTable'
86
- } )
44
+ expectPutsLength ( appState ) . toEqual ( 3 )
45
+ expectPut ( appState , 0 ) . toEqual ( expectedPutGithubWorkflowRunEvent ( testPersonalTestRepoWorkflowRun ) )
46
+ expectPut ( appState , 1 ) . toEqual ( expectedPutGithubWorkflowRun ( testPersonalTestRepoWorkflowRun ) )
47
+ expectPut ( appState , 2 ) . toEqual ( expectedPutLatestGithubWorkflowRunEvent ( testPersonalTestRepoWorkflowRun ) )
87
48
} )
88
49
89
50
test ( 'repo-crawler-for-org-installation' , async ( ) => {
@@ -104,56 +65,8 @@ test('repo-crawler-for-org-installation', async () => {
104
65
await crawlWorkflowRunEvents ( appState , testOrgInstallation , testOrgTestRepoOne , 10 )
105
66
106
67
// A
107
- expect ( appState . dynamoDB . puts . length ) . toEqual ( 3 )
108
- expect ( appState . dynamoDB . puts [ 0 ] ) . toEqual ( {
109
- ConditionExpression : 'attribute_not_exists(PK)' ,
110
- Item : {
111
- PK : 'ACCOUNT#162483619' ,
112
- SK : 'REPO#768206479#WORKFLOW#88647110#WORKFLOW_RUN_EVENT#UPDATED_AT#2024-03-06T17:02:54Z#RUN#8175883775#STATUS#completed' ,
113
- GSI1PK : 'ACCOUNT#162483619' ,
114
- GSI1SK : 'REPO#768206479#DATETIME#2024-03-06T17:02:54Z' ,
115
- _et : 'githubWorkflowRunEvent' ,
116
- _lastUpdated : '2024-02-02T19:00:00.000Z' ,
117
- ...testOrgTestRepoOneWorkflowRunOne
118
- } ,
119
- TableName : 'fakeGithubRepoActivityTable'
120
- } )
121
- expect ( appState . dynamoDB . puts [ 1 ] ) . toEqual ( {
122
- ConditionExpression : 'attribute_not_exists(PK) OR #updatedAt < :newUpdatedAt' ,
123
- ExpressionAttributeNames : {
124
- '#updatedAt' : 'updatedAt'
125
- } ,
126
- ExpressionAttributeValues : {
127
- ':newUpdatedAt' : '2024-03-06T17:02:54Z'
128
- } ,
129
- Item : {
130
- PK : 'ACCOUNT#162483619' ,
131
- SK : 'REPO#768206479#WORKFLOW#88647110#WORKFLOW_RUN#RUN#8175883775' ,
132
- GSI1PK : 'ACCOUNT#162483619' ,
133
- GSI1SK : 'REPO#768206479#DATETIME#2024-03-06T17:02:54Z' ,
134
- _et : 'githubWorkflowRun' ,
135
- _lastUpdated : '2024-02-02T19:00:00.000Z' ,
136
- ...testOrgTestRepoOneWorkflowRunOne
137
- } ,
138
- TableName : 'fakeGithubRepoActivityTable'
139
- } )
140
- expect ( appState . dynamoDB . puts [ 2 ] ) . toEqual ( {
141
- ConditionExpression : 'attribute_not_exists(PK) OR #updatedAt < :newUpdatedAt' ,
142
- ExpressionAttributeNames : {
143
- '#updatedAt' : 'updatedAt'
144
- } ,
145
- ExpressionAttributeValues : {
146
- ':newUpdatedAt' : '2024-03-06T17:02:54Z'
147
- } ,
148
- Item : {
149
- PK : 'ACCOUNT#162483619' ,
150
- SK : 'REPO#768206479#WORKFLOW#88647110' ,
151
- GSI1PK : 'ACCOUNT#162483619' ,
152
- GSI1SK : 'DATETIME#2024-03-06T17:02:54Z' ,
153
- _et : 'githubLatestWorkflowRunEvent' ,
154
- _lastUpdated : '2024-02-02T19:00:00.000Z' ,
155
- ...testOrgTestRepoOneWorkflowRunOne
156
- } ,
157
- TableName : 'fakeGithubLatestWorkflowRunsTable'
158
- } )
68
+ expectPutsLength ( appState ) . toEqual ( 3 )
69
+ expectPut ( appState , 0 ) . toEqual ( expectedPutGithubWorkflowRunEvent ( testOrgTestRepoOneWorkflowRunOne ) )
70
+ expectPut ( appState , 1 ) . toEqual ( expectedPutGithubWorkflowRun ( testOrgTestRepoOneWorkflowRunOne ) )
71
+ expectPut ( appState , 2 ) . toEqual ( expectedPutLatestGithubWorkflowRunEvent ( testOrgTestRepoOneWorkflowRunOne ) )
159
72
} )
0 commit comments