-
Notifications
You must be signed in to change notification settings - Fork 1
/
mock_client.go
93 lines (84 loc) · 2.59 KB
/
mock_client.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package gocdexporter
import (
"encoding/json"
"io/ioutil"
"strconv"
"github.com/pagero/go-gocd-ashwanth"
)
type MockClient struct {
pg []*gocd.PipelineGroup
}
func NewMockClient() *MockClient {
mc := &MockClient{}
f, _ := ioutil.ReadFile("fixtures/get_pipeline_groups.json")
_ = json.Unmarshal([]byte(string(f)), &mc.pg)
return mc
}
func (c *MockClient) GetAllAgents() ([]*gocd.Agent, error) {
f, _ := ioutil.ReadFile("fixtures/get_all_agents.json")
type EmbeddedObj struct {
Agents []*gocd.Agent `json:"agents"`
}
responseFormat := struct {
Embedded EmbeddedObj `json:"_embedded"`
}{}
_ = json.Unmarshal([]byte(string(f)), &responseFormat)
return responseFormat.Embedded.Agents, nil
}
func (c *MockClient) GetAgent(uuid string) (*gocd.Agent, error) {
return nil, nil
}
func (c *MockClient) UpdateAgent(uuid string, agent *gocd.Agent) (*gocd.Agent, error) {
return nil, nil
}
func (c *MockClient) DisableAgent(uuid string) error {
return nil
}
func (c *MockClient) EnableAgent(uuid string) error {
return nil
}
func (c *MockClient) DeleteAgent(uuid string) error {
return nil
}
func (c *MockClient) AgentRunJobHistory(uuid string, offset int, pageSize int) (*gocd.AgentJobRunHistory, error) {
f, _ := ioutil.ReadFile("fixtures/" + uuid + "_agent_job_history_" + strconv.Itoa(offset) + ".json")
h := new(gocd.AgentJobRunHistory)
err := json.Unmarshal([]byte(string(f)), &h)
return h, err
}
func (c *MockClient) GetPipelineGroups() ([]*gocd.PipelineGroup, error) {
return c.pg, nil
}
func (c *MockClient) GetPipelineInstance(string, int) (*gocd.PipelineInstance, error) {
return nil, nil
}
func (c *MockClient) GetPipelineHistoryPage(string, int) (*gocd.PipelineHistoryPage, error) {
return nil, nil
}
func (c *MockClient) GetPipelineStatus(string) (*gocd.PipelineStatus, error) {
return nil, nil
}
func (c *MockClient) PausePipeline(string, string) (*gocd.SimpleMessage, error) {
return nil, nil
}
func (c *MockClient) UnpausePipeline(string) (*gocd.SimpleMessage, error) {
return nil, nil
}
func (c *MockClient) UnlockPipeline(string) (*gocd.SimpleMessage, error) {
return nil, nil
}
func (c *MockClient) GetScheduledJobs() ([]*gocd.ScheduledJob, error) {
return nil, nil
}
func (c *MockClient) GetJobHistory(pipeline, stage, job string) ([]*gocd.JobHistory, error) {
return nil, nil
}
func (c *MockClient) GetAllEnvironmentConfigs() ([]*gocd.EnvironmentConfig, error) {
return nil, nil
}
func (c *MockClient) GetEnvironmentConfig(name string) (*gocd.EnvironmentConfig, error) {
return nil, nil
}
func (c *MockClient) GetServerHealthMessages() ([]*gocd.ServerHealthMessage, error) {
return nil, nil
}