Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with errors when loading big diff #79

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/GitLabHealth-Model-Importer-Tests/GLHApiMock.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Class {
#name : #GLHApiMock,
#superclass : #GLHApi,
#category : #'GitLabHealth-Model-Importer-Tests'
}

{ #category : #'api - commits' }
GLHApiMock >> commitDiff: aCommitID ofProject: aProjectId unidiff: aBoolean [

aCommitID = 'createError' ifTrue: [
^ '{"message":"500 Internal Server Error"}' ]
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
'importer',
'model'
],
#category : 'GitLabHealth-Model-Importer-Tests'
#category : #'GitLabHealth-Model-Importer-Tests'
}

{ #category : #running }
Expand All @@ -18,7 +18,22 @@ GLHModelImporterLocalTest >> setUp [

importer := GLHModelImporter new.
model := GLPHEModel new.
importer glhModel: model
importer glhModel: model.
importer glhApi: GLHApiMock new
]

{ #category : #tests }
GLHModelImporterLocalTest >> testImportDiffOfCommitWithServerRaiseError [

| commit repo project |
commit := model newCommit.
commit id: 'createError'.
repo := model newRepository.
commit repository: repo.
project := model newProject.
repo project: project.
importer importDiffOfCommit: commit.
self assert: commit diffs isEmpty
]

{ #category : #tests }
Expand All @@ -31,3 +46,10 @@ GLHModelImporterLocalTest >> testImportUserAlreadyInModel [
model add: user.
self assert: (importer importUser: 12) equals: user
]

{ #category : #tests }
GLHModelImporterLocalTest >> testIsServerError [

self assert:
(importer isServerError: '{"message":"500 Internal Server Error"}')
]
6 changes: 6 additions & 0 deletions src/GitLabHealth-Model-Importer/GLHModelImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ GLHModelImporter >> importDiffOfCommit: aCommit [
commitDiff: aCommit id
ofProject: aCommit repository project id
unidiff: true.
(self isServerError: result) ifTrue: [ ^ { } ].
diffsResult := self newParseDiffResult: result.

^ aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
Expand Down Expand Up @@ -927,6 +928,11 @@ GLHModelImporter >> initialize [
currentImporter := self
]

{ #category : #api }
GLHModelImporter >> isServerError: aString [
^ aString = '{"message":"500 Internal Server Error"}'
]

{ #category : #importer }
GLHModelImporter >> loadAllProjectsFromRepositorySoftware [
"heavy import that load all the active project inside the model. Only import the project entities"
Expand Down
Loading