Skip to content

Commit b82bb58

Browse files
authored
Merge pull request #58 from Evref-BL/develop
Gitlab-Pharo-API 1.0.2
2 parents dacb8a4 + fd54b30 commit b82bb58

32 files changed

Lines changed: 1769 additions & 1237 deletions

File tree

src/GitlabAPI-Branches-Tests/GitlabBranchesTest.class.st

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,65 @@ Class {
1111
{ #category : 'tests' }
1212
GitlabBranchesTest >> testCreateInProjectFromRef [
1313

14-
| hostUrl gitlabApi branchName projectId ref result client postMessage|
15-
14+
| hostUrl gitlabApi branchName projectId ref result client postMessage |
1615
"Given"
1716
hostUrl := 'www.url.com'.
1817
client := ZnClient new.
1918
postMessage := 'success'.
20-
21-
client stub post willReturn: '{"message": "', postMessage, '"}'.
22-
gitlabApi := GitlabApi new privateToken: 'token'; hostUrl: hostUrl; client: client.
23-
19+
20+
client stub post willReturn: '{"message": "' , postMessage , '"}'.
21+
gitlabApi := GitlabApi new
22+
privateToken: 'token';
23+
hostUrl: hostUrl;
24+
client: client.
25+
2426
branchName := 'test'.
2527
projectId := 1.
2628
ref := 'main'.
27-
29+
2830
"When"
29-
result := gitlabApi branches create: branchName inProject: projectId fromRef: ref.
30-
31+
result := gitlabApi branches
32+
create: branchName
33+
inProject: projectId
34+
fromRef: ref.
35+
3136
"Then"
3237
(client request url query at: #branch) should be: branchName.
3338
(client request url query at: #ref) should be: ref.
3439
self assert: (result at: #message) equals: postMessage
35-
3640
]
3741

3842
{ #category : 'tests' }
3943
GitlabBranchesTest >> testGetAllFromProject [
4044

4145
| hostUrl gitlabApi projectId result client branch1 branch2 gitlabBranches endpoint |
42-
4346
"Given"
4447
hostUrl := 'www.url.com'.
4548
client := Mock new.
46-
47-
gitlabApi := GitlabApi new privateToken: 'token'; hostUrl: hostUrl; client: client; output: 'json'.
48-
49+
50+
gitlabApi := GitlabApi new
51+
privateToken: 'token';
52+
hostUrl: hostUrl;
53+
client: client;
54+
output: 'json'.
55+
4956
gitlabBranches := GitlabBranches new gitlabAPI: gitlabApi.
50-
57+
5158
branch1 := '{"name": "branch1"}'.
5259
branch2 := '{"name": "branch2"}'.
5360
projectId := 1.
54-
55-
endpoint := '/projects/', projectId asString, '/repository/branches'.
56-
(gitlabBranches stub getAll: endpoint withParams: Dictionary new) willReturn: { branch1. branch2 }.
57-
61+
62+
endpoint := '/projects/' , projectId asString
63+
, '/repository/branches'.
64+
(gitlabBranches stub getAll: endpoint withParams: Dictionary new)
65+
willReturn: {
66+
branch1.
67+
branch2 }.
68+
5869
"When"
5970
result := gitlabBranches getAllFromProject: projectId.
60-
71+
6172
"Then"
6273
self assert: result size equals: 2.
63-
self assert: (result first) equals: branch1.
74+
self assert: result first equals: branch1
6475
]

src/GitlabAPI-Branches/GitlabBranches.class.st

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ GitlabBranches >> create: name inProject: projectId fromRef: ref [
1111

1212
| response |
1313
gitlabAPI client url:
14-
gitlabAPI hostUrl , '/projects/' , projectId asString , '/repository/branches'.
14+
gitlabAPI hostUrl , '/projects/' , projectId asString
15+
, '/repository/branches'.
1516
gitlabAPI client queryAt: #branch put: name.
1617
gitlabAPI client queryAt: #ref put: ref.
1718
response := gitlabAPI client post.
18-
19-
^NeoJSONReader fromString: response.
19+
20+
^ NeoJSONReader fromString: response
2021
]
2122

2223
{ #category : 'api' }
2324
GitlabBranches >> getAllFromProject: projectId [
24-
"https://docs.gitlab.com/ee/api/branches.html#list-repository-branches"
25+
"https://docs.gitlab.com/ee/api/branches.html#list-repository-branches"
26+
2527
| endpoint |
26-
endpoint := '/projects/', projectId asString, '/repository/branches'.
27-
28-
^self getAll: endpoint withParams: Dictionary new.
28+
endpoint := '/projects/' , projectId asString
29+
, '/repository/branches'.
30+
31+
^ self getAll: endpoint withParams: Dictionary new
2932
]

src/GitlabAPI-Commits-Tests/GitlabActionTest.class.st

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,44 @@ Class {
1010

1111
{ #category : 'tests' }
1212
GitlabActionTest >> testAsDictionary [
13-
1413
"Given"
14+
1515
| action filePath content gitlabAction dict |
1616
action := 'update'.
1717
filePath := 'file.txt'.
1818
content := 'content'.
19-
20-
gitlabAction := GitlabAction new action: action; content: content; filePath: filePath.
21-
19+
20+
gitlabAction := GitlabAction new
21+
action: action;
22+
content: content;
23+
filePath: filePath.
24+
2225
"When"
2326
dict := gitlabAction asDictionary.
24-
27+
2528
"Then"
2629
self assert: (dict at: #action) equals: action.
2730
self assert: (dict at: #file_path) equals: filePath.
28-
self assert: (dict at: #content) equals: content.
29-
31+
self assert: (dict at: #content) equals: content
3032
]
3133

3234
{ #category : 'tests' }
3335
GitlabActionTest >> testAsDictionaryWithoutParams [
34-
3536
"Given"
37+
3638
| action filePath gitlabAction dict |
3739
action := 'update'.
3840
filePath := 'file.txt'.
39-
40-
gitlabAction := GitlabAction new action: action; filePath: filePath.
41-
41+
42+
gitlabAction := GitlabAction new
43+
action: action;
44+
filePath: filePath.
45+
4246
"When"
4347
dict := gitlabAction asDictionary.
44-
48+
4549
"Then"
4650
self assert: (dict at: #action) equals: action.
4751
self assert: (dict at: #file_path) equals: filePath.
48-
self assert: (dict includesKey: #content) equals: false.
49-
52+
self assert: (dict includesKey: #content) equals: false
5053
]

0 commit comments

Comments
 (0)