Skip to content

Commit

Permalink
add test with test resources
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed Jun 14, 2024
1 parent fca7bff commit ca96c88
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 29 deletions.
36 changes: 11 additions & 25 deletions src/GitLabHealth-Model-Importer-Tests/GLHModelImporterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,23 @@ Class {
#category : #'GitLabHealth-Model-Importer-Tests'
}

{ #category : #'class initialization' }
GLHModelImporterTest class >> initialize [
{ #category : #accessing }
GLHModelImporterTest class >> resources [


^ Array with: GLHModelImporterTestResource
]

{ #category : #running }
GLHModelImporterTest >> setUp [
GLHModelImporterTest >> model [

super setUp.

"Put here a common initialization logic for tests"
glphModel := GLPHEModel new.

glphApi := GLPHApi new
privateToken: '';
baseAPIUrl: 'https://gitlab.com/api/v4';
yourself.

since := Date today - 2 day.

glhImporter := GLPHModelImporter new
glhApi: glphApi;
glhModel: glphModel;
withFiles: false;
withCommitsSince: 0 day;
withCommitDiffs: true.

glhImporter importGroup: 87194534.
^ self class resources first current model
]

{ #category : #tests }
GLHModelImporterTest >> testImport [
GLHModelImporterTest >> testImportProject [

self assert: (self model allWithType: GLHProject) size equals: 1.
self assert:
((self model allWithType: GLHProject) anySatisfy: [ :project |
project id = 57841283 ])
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Class {
#name : #GLHModelImporterTestResource,
#superclass : #MooseModelTestResource,
#instVars : [
'glphApi',
'since',
'glhImporter'
],
#category : #'GitLabHealth-Model-Importer-Tests'
}

{ #category : #setup }
GLHModelImporterTestResource >> importModel [

model := GLPHEModel new.

glphApi := GLPHApi new
privateToken: '';
baseAPIUrl: 'https://gitlab.com/api/v4';
yourself.

since := Date today - 2 day.

glhImporter := GLPHModelImporter new
glhApi: glphApi;
glhModel: model;
withFiles: false;
withCommitsSince: 0 day;
withCommitDiffs: true.

glhImporter importGroup: 87194534
]
9 changes: 5 additions & 4 deletions src/GitLabHealth-Model-Importer/GLHModelImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ GLHModelImporter >> addCommits: commitsList toRepository: aProjectRepository [
{ #category : #private }
GLHModelImporter >> addGroupResultToModel: groupResult [

self glhModel add: groupResult.
self glhModel addAll: groupResult projects
self glhModel add: groupResult unless: (self blockEqualityOn: #id).
self glhModel
addAll: groupResult projects
unless: (self blockEqualityOn: #id)
]

{ #category : #accessing }
Expand Down Expand Up @@ -524,8 +526,7 @@ GLHModelImporter >> importGroup: aGroupID [
self completeImportProject: project ].
self addGroupResultToModel: groupResult.
(self subGroupsOf: aGroupID) do: [ :subGroup |

groupResult addSubGroup: (self importGroup: subGroup id) ].
groupResult addSubGroup: (self importGroup: subGroup id) ].
^ groupResult
]

Expand Down

0 comments on commit ca96c88

Please sign in to comment.