forked from TheQuestionru/newrelic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
applications_test_fixtures.go
165 lines (160 loc) · 3.38 KB
/
applications_test_fixtures.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package newrelic
type getApplicationsTestsInput struct {
options *ApplicationOptions
data string
}
type getApplicationsTestsOutput struct {
data []Application
err error
}
type getApplicationTestsInput struct {
id int
data string
}
type getApplicationTestsOutput struct {
data *Application
err error
}
var (
testApplicationJSON = `
{
"application_summary": {
"apdex_score": 1.0,
"apdex_target": 0.5,
"error_rate": 0.0,
"host_count": 1,
"instance_count": 1,
"response_time": 0.263,
"throughput": 12.3
},
"end_user_summary": {
"response_time": 0.263,
"throughput": 12.3,
"apdex_target": 0.5,
"apdex_score": 1
},
"health_status": "green",
"id": 12345,
"language": "java",
"last_reported_at": "` + testTimeRawString + `",
"links": {
"alert_policy": 123,
"application_hosts": [
1234567
],
"application_instances": [
1234568
],
"servers": [
54321
]
},
"name": "test.example.com",
"reporting": true,
"settings": {
"app_apdex_threshold": 0.5,
"enable_real_user_monitoring": true,
"end_user_apdex_threshold": 1.0,
"use_server_side_config": false
}
}
`
testApplication = Application{
ID: 12345,
Name: "test.example.com",
Language: "java",
HealthStatus: "green",
Reporting: true,
LastReportedAt: testTime,
ApplicationSummary: ApplicationSummary{
ResponseTime: 0.263,
Throughput: 12.3,
ErrorRate: 0,
ApdexTarget: 0.5,
ApdexScore: 1,
HostCount: 1,
InstanceCount: 1,
ConcurrentInstanceCount: 0,
},
EndUserSummary: EndUserSummary{
ResponseTime: 0.263,
Throughput: 12.3,
ApdexTarget: 0.5,
ApdexScore: 1,
},
Settings: Settings{
AppApdexThreshold: 0.5,
EndUserApdexThreshold: 1,
EnableRealUserMonitoring: true,
UseServerSideConfig: false,
},
Links: Links{
Servers: []int{54321},
ApplicationHosts: []int{1234567},
ApplicationInstances: []int{1234568},
AlertPolicy: 123,
},
}
testApplications = []Application{
testApplication,
testApplication,
}
getApplicationTests = []struct {
in getApplicationTestsInput
out getApplicationTestsOutput
}{
{
getApplicationTestsInput{
id: 12345,
data: `{ "application":` + testApplicationJSON + `}`,
},
getApplicationTestsOutput{
data: &testApplication,
},
},
}
getApplicationsTests = []struct {
in getApplicationsTestsInput
out getApplicationsTestsOutput
}{
{
getApplicationsTestsInput{
options: nil,
data: `{"applications":[` + testApplicationJSON + "," + testApplicationJSON + "]}",
},
getApplicationsTestsOutput{
data: testApplications,
err: nil,
},
},
}
applicationOptionsStringerTests = []struct {
in *ApplicationOptions
out string
}{
{
&ApplicationOptions{},
"",
},
{
&ApplicationOptions{
Filter: ApplicationFilter{
Name: "testName",
Host: "testHost",
IDs: []int{123, 456},
Language: "java",
},
Page: 5,
},
`filter%5Bhost%5D=testHost` +
`&filter%5Bids%5D=123%2C456` +
`&filter%5Blanguage%5D=java` +
`&filter%5Bname%5D=testName` +
`&page=5`,
},
{
nil,
"",
},
}
)