/
pulsar_job.go
70 lines (63 loc) · 2.11 KB
/
pulsar_job.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package mockns1
import (
"fmt"
"net/http"
"gopkg.in/ns1/ns1-go.v2/rest/model/pulsar"
)
// AddPulsarJobListTestCase sets up a test case for the api.Client.PulsarJobs.List()
// function
func (s *Service) AddPulsarJobListTestCase(
appid string,
requestHeaders, responseHeaders http.Header,
response []*pulsar.PulsarJob,
) error {
return s.AddTestCase(
http.MethodGet, fmt.Sprintf("/pulsar/apps/%s/jobs", appid), http.StatusOK, requestHeaders,
responseHeaders, "", response,
)
}
// AddPulsarJobGetTestCase sets up a test case for the api.Client.PulsarJobs.Get()
// function
func (s *Service) AddPulsarJobGetTestCase(
appid, jobid string,
requestHeaders, responseHeaders http.Header,
response *pulsar.PulsarJob,
) error {
return s.AddTestCase(
http.MethodGet, fmt.Sprintf("/pulsar/apps/%s/jobs/%s", appid, jobid), http.StatusOK, requestHeaders,
responseHeaders, "", response,
)
}
// AddPulsarJobGetTestCase sets up a test case for the api.Client.PulsarJobs.Create()
// function
func (s *Service) AddPulsarJobCreateTestCase(
requestHeaders, responseHeaders http.Header,
pulsarJob, response *pulsar.PulsarJob,
) error {
return s.AddTestCase(
http.MethodPut, fmt.Sprintf("pulsar/apps/%s/jobs", pulsarJob.AppID), http.StatusOK, requestHeaders,
responseHeaders, pulsarJob, response,
)
}
// AddPulsarJobGetTestCase sets up a test case for the api.Client.PulsarJobs.Update()
// function
func (s *Service) AddPulsarJobUpdateTestCase(
requestHeaders, responseHeaders http.Header,
pulsarJob, response *pulsar.PulsarJob,
) error {
return s.AddTestCase(
http.MethodPost, fmt.Sprintf("pulsar/apps/%s/jobs/%s", pulsarJob.AppID, pulsarJob.JobID), http.StatusOK, requestHeaders,
responseHeaders, pulsarJob, response,
)
}
// AddPulsarJobGetTestCase sets up a test case for the api.Client.PulsarJobs.Delete()
// function
func (s *Service) AddPulsarJobDeleteTestCase(
requestHeaders, responseHeaders http.Header,
pulsarJob, response *pulsar.PulsarJob,
) error {
return s.AddTestCase(
http.MethodDelete, fmt.Sprintf("pulsar/apps/%s/jobs/%s", pulsarJob.AppID, pulsarJob.JobID), http.StatusOK, requestHeaders,
responseHeaders, "", "",
)
}