Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
74 changes: 74 additions & 0 deletions src/GitlabAPI-Jobs-Tests/GitlabJobsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,77 @@ GitlabJobsTest >> testAllForPipelineInProject [
self assert: result size equals: 1.
self assert: (result first at: #id) equals: objectId.
]

{ #category : 'tests' }
GitlabJobsTest >> testGetByPagePerPageInProject [

| gitlabApi projectId page perPage objects object result gitlabJobs |
"Given"
gitlabApi := GitlabApi new
privateToken: 'token';
hostUrl: 'https://www.url.com';
client: ZnClient new.

projectId := 1.
page := 1.
perPage := 3.

object := { (#id -> 4) } asDictionary.
objects := { object }.

gitlabJobs := GitlabJobs new gitlabAPI: gitlabApi.

(gitlabJobs stub
getByPage: page
perPage: perPage
inProject: projectId
withParams: Dictionary new) willReturn: objects.

"When"
result := gitlabJobs
getByPage: page
perPage: perPage
inProject: projectId.

"Then"
self assert: result size equals: 1.
self assert: result first equals: object
]

{ #category : 'tests' }
GitlabJobsTest >> testGetByPagePerPageInProjectWithParams [

| gitlabApi projectId page perPage params objects object result gitlabJobs |
"Given"
gitlabApi := GitlabApi new
privateToken: 'token';
hostUrl: 'https://www.url.com';
client: ZnClient new.

projectId := 1.
page := 1.
perPage := 3.
params := { ('param' -> 'value') } asDictionary.

object := { (#id -> 4) } asDictionary.
objects := { object }.

gitlabJobs := GitlabJobs new gitlabAPI: gitlabApi.

(gitlabJobs stub
getByPage: page
perPage: perPage
inProject: projectId
withParams: params) willReturn: objects.
Comment on lines +97 to +101

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: You’re stubbing the method you’re trying to test. You should stub the method it depends on instead. In this case it would be getByPage:perPage:from:withParams: i think


"When"
result := gitlabJobs
getByPage: page
perPage: perPage
inProject: projectId
withParams: params.

"Then"
self assert: result size equals: 1.
self assert: result first equals: object
]
20 changes: 20 additions & 0 deletions src/GitlabAPI-Jobs/GitlabJobs.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,23 @@ GitlabJobs >> getAllForPipeline: pipelineId inProject: projectId includingRetrie

^self getAll: endpoint withParams: params
]

{ #category : 'api' }
GitlabJobs >> getByPage: page perPage: perPage inProject: projectId [

^ self
getByPage: page
perPage: perPage
inProject: projectId
withParams: Dictionary new
]

{ #category : 'api' }
GitlabJobs >> getByPage: page perPage: perPage inProject: projectId withParams: params [

^ self
getByPage: page
perPage: perPage
from: '/projects/' , projectId asString , '/jobs'
withParams: params
]
Loading