|
1 | | -" |
2 | | -A CodeAdditionByMergeRequestProjectMetricTest is a test class for testing the behavior of CodeAdditionByMergeRequestProjectMetric |
3 | | -" |
4 | | -Class { |
5 | | - #name : #CodeAdditionByMergeRequestProjectMetricTest, |
6 | | - #superclass : #ProjectMetricTest, |
7 | | - #category : #'GitLabHealth-Model-Analysis-Tests' |
8 | | -} |
9 | | - |
10 | | -{ #category : #tests } |
11 | | -CodeAdditionByMergeRequestProjectMetricTest >> testCalculate [ |
12 | | - |
13 | | - | result glhImporter codeAddition mergedCommit | |
14 | | - glhImporter := GLPHImporterMock new. |
15 | | - mergedCommit := GLHCommit new |
16 | | - id: 4; |
17 | | - additions: 42; |
18 | | - deletions: 78. |
19 | | - glhImporter mergeRequests: { (GLHMergeRequest new |
20 | | - project: project2; |
21 | | - created_at: createdAt; |
22 | | - merged_at: mergedAt; |
23 | | - mergedCommit: mergedCommit; |
24 | | - state: #merged) }. |
25 | | - |
26 | | - glhImporter commits: { |
27 | | - (GLHCommit new |
28 | | - id: 1; |
29 | | - additions: 7; |
30 | | - deletions: 5). |
31 | | - (GLHCommit new |
32 | | - id: 2; |
33 | | - additions: 3; |
34 | | - deletions: 5). |
35 | | - (GLHCommit new |
36 | | - id: 3; |
37 | | - additions: 3; |
38 | | - deletions: 5) }. |
39 | | - |
40 | | - |
41 | | - codeAddition := CodeAdditionByMergeRequestProjectMetric new |
42 | | - project: project2; |
43 | | - glhImporter: glhImporter; |
44 | | - setPeriodSince: since until: until; |
45 | | - over: Week. |
46 | | - |
47 | | - "When" |
48 | | - result := codeAddition calculate. |
49 | | - |
50 | | - "Then" |
51 | | - self assert: result equals: 42 |
52 | | -] |
53 | | - |
54 | | -{ #category : #tests } |
55 | | -CodeAdditionByMergeRequestProjectMetricTest >> testCalculateMROpenOnly [ |
56 | | - |
57 | | - | result glhImporter codeAddition | |
58 | | - glhImporter := GLPHImporterMock new. |
59 | | - glhImporter mergeRequests: { (GLHMergeRequest new |
60 | | - project: project1; |
61 | | - created_at: createdAt ; |
62 | | - merged_at: mergedAt ; |
63 | | - state: #opened ) }. |
64 | | - |
65 | | - codeAddition := CodeAdditionByMergeRequestProjectMetric new |
66 | | - project: project1; |
67 | | - glhImporter: glhImporter; |
68 | | - setPeriodSince: since until: until; |
69 | | - over: Week. |
70 | | - |
71 | | - "When" |
72 | | - result := codeAddition calculate. |
73 | | - |
74 | | - "Then" |
75 | | - self assert: result equals: 0 |
76 | | -] |
77 | | - |
78 | | -{ #category : #tests } |
79 | | -CodeAdditionByMergeRequestProjectMetricTest >> testCalculateNoCommits [ |
80 | | - |
81 | | - | result glhImporter codeAddition | |
82 | | - glhImporter := GLPHImporterMock new. |
83 | | - glhImporter mergeRequests: { (GLHMergeRequest new |
84 | | - project: project1; |
85 | | - created_at: createdAt ; |
86 | | - merged_at: mergedAt ; |
87 | | - state: #closed ) }. |
88 | | - |
89 | | - codeAddition := CodeAdditionByMergeRequestProjectMetric new |
90 | | - project: project1; |
91 | | - glhImporter: glhImporter; |
92 | | - setPeriodSince: since until: until; |
93 | | - over: Week. |
94 | | - |
95 | | - "When" |
96 | | - result := codeAddition calculate. |
97 | | - |
98 | | - "Then" |
99 | | - self assert: result equals: 0 |
100 | | -] |
101 | | - |
102 | | -{ #category : #tests } |
103 | | -CodeAdditionByMergeRequestProjectMetricTest >> testCalculateNoMergeRequests [ |
104 | | - |
105 | | - | result glhImporter codeAddition | |
106 | | - glhImporter := GLPHImporterMock new. |
107 | | - |
108 | | - codeAddition := CodeAdditionByMergeRequestProjectMetric new |
109 | | - project: project1 ; |
110 | | - glhImporter: glhImporter; |
111 | | - setPeriodSince: since until: until; |
112 | | - over: Week. |
113 | | - |
114 | | - "When" |
115 | | - result := codeAddition calculate. |
116 | | - |
117 | | - "Then" |
118 | | - self assert: result equals: 0 |
119 | | -] |
| 1 | +" |
| 2 | +A CodeAdditionByMergeRequestProjectMetricTest is a test class for testing the behavior of CodeAdditionByMergeRequestProjectMetric |
| 3 | +" |
| 4 | +Class { |
| 5 | + #name : #CodeAdditionByMergeRequestProjectMetricTest, |
| 6 | + #superclass : #ProjectMetricTest, |
| 7 | + #category : #'GitLabHealth-Model-Analysis-Tests' |
| 8 | +} |
| 9 | + |
| 10 | +{ #category : #tests } |
| 11 | +CodeAdditionByMergeRequestProjectMetricTest >> testCalculate [ |
| 12 | + |
| 13 | + | result glhImporter codeAddition mergedCommit | |
| 14 | + glhImporter := GLPHImporterMock new. |
| 15 | + mergedCommit := GLHCommit new |
| 16 | + id: 4; |
| 17 | + additions: 42; |
| 18 | + deletions: 78. |
| 19 | + glhImporter mergeRequests: { (GLHMergeRequest new |
| 20 | + project: project2; |
| 21 | + created_at: createdAt; |
| 22 | + merged_at: mergedAt; |
| 23 | + mergedCommit: mergedCommit; |
| 24 | + state: #merged) }. |
| 25 | + |
| 26 | + glhImporter commits: { |
| 27 | + (GLHCommit new |
| 28 | + id: 1; |
| 29 | + additions: 7; |
| 30 | + deletions: 5). |
| 31 | + (GLHCommit new |
| 32 | + id: 2; |
| 33 | + additions: 3; |
| 34 | + deletions: 5). |
| 35 | + (GLHCommit new |
| 36 | + id: 3; |
| 37 | + additions: 3; |
| 38 | + deletions: 5) }. |
| 39 | + |
| 40 | + |
| 41 | + codeAddition := CodeAdditionByMergeRequestProjectMetric new |
| 42 | + project: project2; |
| 43 | + glhImporter: glhImporter; |
| 44 | + setPeriodSince: since until: until; |
| 45 | + over: Week. |
| 46 | + |
| 47 | + "When" |
| 48 | + result := codeAddition calculate. |
| 49 | + |
| 50 | + "Then" |
| 51 | + self assert: result equals: 42 |
| 52 | +] |
| 53 | + |
| 54 | +{ #category : #tests } |
| 55 | +CodeAdditionByMergeRequestProjectMetricTest >> testCalculateMROpenOnly [ |
| 56 | + |
| 57 | + | result glhImporter codeAddition | |
| 58 | + glhImporter := GLPHImporterMock new. |
| 59 | + glhImporter mergeRequests: { (GLHMergeRequest new |
| 60 | + project: project1; |
| 61 | + created_at: createdAt ; |
| 62 | + merged_at: mergedAt ; |
| 63 | + state: #opened ) }. |
| 64 | + |
| 65 | + codeAddition := CodeAdditionByMergeRequestProjectMetric new |
| 66 | + project: project1; |
| 67 | + glhImporter: glhImporter; |
| 68 | + setPeriodSince: since until: until; |
| 69 | + over: Week. |
| 70 | + |
| 71 | + "When" |
| 72 | + result := codeAddition calculate. |
| 73 | + |
| 74 | + "Then" |
| 75 | + self assert: result equals: 0 |
| 76 | +] |
| 77 | + |
| 78 | +{ #category : #tests } |
| 79 | +CodeAdditionByMergeRequestProjectMetricTest >> testCalculateNoCommits [ |
| 80 | + |
| 81 | + | result glhImporter codeAddition | |
| 82 | + glhImporter := GLPHImporterMock new. |
| 83 | + glhImporter mergeRequests: { (GLHMergeRequest new |
| 84 | + project: project1; |
| 85 | + created_at: createdAt ; |
| 86 | + merged_at: mergedAt ; |
| 87 | + state: #closed ) }. |
| 88 | + |
| 89 | + codeAddition := CodeAdditionByMergeRequestProjectMetric new |
| 90 | + project: project1; |
| 91 | + glhImporter: glhImporter; |
| 92 | + setPeriodSince: since until: until; |
| 93 | + over: Week. |
| 94 | + |
| 95 | + "When" |
| 96 | + result := codeAddition calculate. |
| 97 | + |
| 98 | + "Then" |
| 99 | + self assert: result equals: 0 |
| 100 | +] |
| 101 | + |
| 102 | +{ #category : #tests } |
| 103 | +CodeAdditionByMergeRequestProjectMetricTest >> testCalculateNoMergeRequests [ |
| 104 | + |
| 105 | + | result glhImporter codeAddition | |
| 106 | + glhImporter := GLPHImporterMock new. |
| 107 | + |
| 108 | + codeAddition := CodeAdditionByMergeRequestProjectMetric new |
| 109 | + project: project1 ; |
| 110 | + glhImporter: glhImporter; |
| 111 | + setPeriodSince: since until: until; |
| 112 | + over: Week. |
| 113 | + |
| 114 | + "When" |
| 115 | + result := codeAddition calculate. |
| 116 | + |
| 117 | + "Then" |
| 118 | + self assert: result equals: 0 |
| 119 | +] |
0 commit comments