Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
2ed3911a
Unverified
Commit
2ed3911a
authored
Oct 03, 2017
by
David McKay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding GET request for Slack Integration on a Project
parent
d11d546f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
0 deletions
+81
-0
services.go
services.go
+25
-0
services_test.go
services_test.go
+56
-0
No files found.
services.go
View file @
2ed3911a
...
...
@@ -277,3 +277,28 @@ func (s *ServicesService) DeleteSlackService(pid interface{}, options ...OptionF
return
s
.
client
.
Do
(
req
,
nil
)
}
// GetSlackService gets Slack service settings for a project.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/services.html#get-slack-service-settings
func
(
s
*
ServicesService
)
GetSlackService
(
pid
interface
{},
options
...
OptionFunc
)
(
*
SetSlackServiceOptions
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/services/slack"
,
url
.
QueryEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
opt
:=
new
(
SetSlackServiceOptions
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
opt
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
opt
,
resp
,
err
}
services_test.go
View file @
2ed3911a
...
...
@@ -58,3 +58,59 @@ func TestGetDroneCIService(t *testing.T) {
t
.
Errorf
(
"Services.GetDroneCIService returned %+v, want %+v"
,
service
,
want
)
}
}
func
TestSetSlackService
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/projects/1/services/slack"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"PUT"
)
})
opt
:=
&
SetSlackServiceOptions
{
WebHook
:
String
(
"webhook_uri"
),
Username
:
String
(
"username"
),
Channel
:
String
(
"#development"
),
}
_
,
err
:=
client
.
Services
.
SetSlackService
(
1
,
opt
)
if
err
!=
nil
{
t
.
Fatalf
(
"Services.SetSlackService returns an error: %v"
,
err
)
}
}
func
TestDeleteSlackService
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/projects/1/services/slack"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"DELETE"
)
})
_
,
err
:=
client
.
Services
.
DeleteSlackService
(
1
)
if
err
!=
nil
{
t
.
Fatalf
(
"Services.DeleteSlackService returns an error: %v"
,
err
)
}
}
func
TestGetSlackService
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/projects/1/services/slack"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprint
(
w
,
`{"id":1}`
)
})
want
:=
&
SetSlackServiceOptions
{}
service
,
_
,
err
:=
client
.
Services
.
GetSlackService
(
1
)
if
err
!=
nil
{
t
.
Fatalf
(
"Services.GetSlackService returns an error: %v"
,
err
)
}
if
!
reflect
.
DeepEqual
(
want
,
service
)
{
t
.
Errorf
(
"Services.GetSlackService returned %+v, want %+v"
,
service
,
want
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment