Skip to content

Commit

Permalink
fix: GitlabHealth-Model-Analysis-Tests package is not in coverage (#62)
Browse files Browse the repository at this point in the history
* fix: typo in gitlab package name in smalltalk.ston

* chore: add gitlabHealth-model-analysis-tests in core baseline

* fix: test closedMergeRequestMetric

* test: add tests for reviewedByUserMergeRequestMetric and SelfMergedUnderAMinuteMergeRequestMetric
  • Loading branch information
knowbased authored Sep 18, 2024
1 parent cb9dd03 commit 2dfe0a0
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .smalltalk.ston
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SmalltalkCISpec {
}
],
#testing: {
#packages : [ 'GitLab*', 'GLPH.*', 'GitHub.*', 'GitProject.*' ],
#packages : [ 'GitLab.*', 'GLPH.*', 'GitHub.*', 'GitProject.*' ],
#coverage : {
#packages : [ 'GitLab.*', 'GLPH.*', 'GitHub.*', 'GitProject.*' ],
#format : #lcov
Expand Down
5 changes: 3 additions & 2 deletions src/BaselineOfGitLabHealth/BaselineOfGitLabHealth.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ BaselineOfGitLabHealth >> defineGroups: spec [
spec
group: 'Jira'
with:
#( 'GitProject-JiraConnector' 'GitProject-JiraConnector-Generator' 'GitProject-JiraConnector-Tests' ).
#( 'GitProject-JiraConnector' 'GitProject-JiraConnector-Generator'
'GitProject-JiraConnector-Tests' ).
spec
group: 'Core'
with: #( 'GitLabHealth-Model' 'GitLabHealth-Model-Extension'
Expand All @@ -66,7 +67,7 @@ BaselineOfGitLabHealth >> defineGroups: spec [
'GitLabHealth-Model-Importer' 'GitLabHealth-Model-Importer-Tests'
'GitHubHealth-Model-Importer-Tests'
'GLPHExtended-Model' 'GLPHExtended-Model-Tests'
'GLPHExtended-Model-Extension' 'GitLabHealth-Model-Analysis'
'GLPHExtended-Model-Extension' 'GitLabHealth-Model-Analysis' 'GitLabHealth-Model-Analysis-Tests'
'GitLabHealth-Visualization' 'GitLabProjectHealth-ExtendModel-Generator'
'GitLabProjectHealth-Model-Importer'
'GitLabProjectHealth-Model-Importer-Tests' ).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ ClosedMergeRequestMetricTest >> testCalculate1MRinPeriod2Outside [
created_at: '09-05-2024';
merged_at: nil;
state: 'closed').
(GLPHEMergeRequest new
(GLPHEMergeRequest new
author: user;
created_at: '08-01-2024';
merged_at: nil;
state: 'closed')}.
state: 'closed') }.


closedMergeRequestMetric := ClosedMergeRequestMetric new
user: user;
glhImporter: glhImporter;
setPeriodSince: '08-01-2024'
until: '08-05-2024';
setPeriodSince: '07-28-2024'
until: '08-03-2024';
over: Week.

"When"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,45 @@ ReviewedByUserMergeRequestMetricTest >> testCalculateNoMergeRequests [
self assert: result equals: 0
]

{ #category : #tests }
ReviewedByUserMergeRequestMetricTest >> testCalculateReviewButNotCreated [

| result glhImporter user mergedMergeRequestWithoutReview user2 |
"Given"
user := GLHUser new
name: 'testUser';
contributedProjects:
{ (GLHProject new repository: GLHRepository new) }.
user2 := GLHUser new
name: 'testUser2';
contributedProjects:
{ (GLHProject new repository: GLHRepository new) }.

glhImporter := GLPHImporterMock new.
glhImporter mergeRequests: {
(GLPHEMergeRequest new
author: user2;
merge_user: user2;
reviewers: { user };
created_at: '09-05-2024:00-00-00' asDateAndTime;
merged_at: '09-05-2024:00-00-01' asDateAndTime). }.


mergedMergeRequestWithoutReview := ReviewedByUserMergeRequestMetric
new
user: user;
glhImporter: glhImporter;
setPeriodSince: '09-04-2024'
until: '09-04-2024';
over: Week.

"When"
result := mergedMergeRequestWithoutReview calculate.

"Then"
self assert: result equals: 1
]

{ #category : #test }
ReviewedByUserMergeRequestMetricTest >> testCalculateReviewByOther [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,51 @@ SelfMergedUnderAMinuteMergeRequestMetricTest >> testCalculate [
self assert: result equals: 1
]

{ #category : #tests }
SelfMergedUnderAMinuteMergeRequestMetricTest >> testCalculateMergeButNotCreated [

| result glhImporter user mergedMergeRequestWithoutReview user2 |
"Given"
user := GLHUser new
username: 'test';
contributedProjects:
{ (GLHProject new repository: GLHRepository new) }.

user2 := GLHUser new
name: 'testUser2';
contributedProjects:
{ (GLHProject new repository: GLHRepository new) }.

glhImporter := GLPHImporterMock new.
glhImporter mergeRequests: {
(GLPHEMergeRequest new
author: user2;
merge_user: user;
reviewers: { user };
created_at: '09-05-2024:00-00-00' asDateAndTime;
merged_at: '09-05-2024:00-00-01' asDateAndTime).
(GLPHEMergeRequest new
author: user;
merge_user: nil;
created_at: '09-05-2024:00-00-00' asDateAndTime;
merged_at: '09-05-2024:00-00-01' asDateAndTime) }.


mergedMergeRequestWithoutReview := SelfMergedUnderAMinuteMergeRequestMetric
new
user: user;
glhImporter: glhImporter;
setPeriodSince: '09-04-2024'
until: '09-04-2024';
over: Week.

"When"
result := mergedMergeRequestWithoutReview calculate.

"Then"
self assert: result equals: 0
]

{ #category : #tests }
SelfMergedUnderAMinuteMergeRequestMetricTest >> testCalculateNoMergeRequests [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ SelfMergedUnderAMinuteMergeRequestMetric >> description [
SelfMergedUnderAMinuteMergeRequestMetric >> load [

userMergeRequests := self
loadCompleteMergeRequestsSince: (period at: #since)
loadUserCompleteMergeRequestsSince:
(period at: #since)
until: (period at: #until)
]

Expand Down

0 comments on commit 2dfe0a0

Please sign in to comment.