Commit eed41cd
committed
tests: Avoid use of global mocked server
The meat of this changes is in 'testhelper/http_responses.go' and
'testhelper/client/fake.go'. The rest of the change is bulk generated
updates to handle those changes:
Create a "FakeServer" instance instead of configuring the global fake:
sed -i 's/th.SetupHTTP/fakeServer := th.SetupHTTP/g' $(ag 'th.SetupHTTP' -l)
Tear down this instance on test completion:
sed -i 's/defer th.TeardownHTTP/defer fakeServer.Teardown/g' $(ag 'defer th.TeardownHTTP' -l)
Update calls to the global 'Mux' instance with calls to the FakeServer
version:
sed -i 's/th.Mux.HandleFunc/fakeServer.Mux.HandleFunc/g' $(ag 'th.Mux.HandleFunc' -l)
Update calls to ServiceClient to include a 'FakeServer' parameter:
sed -i 's/client.ServiceClient()/client.ServiceClient(fakeServer)/' $(ag -w client.ServiceClient -l)
Plus alises for the same:
sed -i 's/fake.ServiceClient()/fake.ServiceClient(fakeServer)/' $(ag 'fake.ServiceClient' -l)
Update definitions and calls to various MockFoo and HandleFoo helpers -
plus lowercase, private variants of same - to include a 'FakeServer'
parameter:
sed -i 's/\(func Mock\w\+(t \*testing.T\)/\1, fakeServer th.FakeServer/' $(ag 'func Mock\w+\(t \*testing.T' -l)
sed -i 's/\(\tMock\w\+(t\)/\1, fakeServer/' $(ag '\tMock\w+\(t' -l)
sed -i 's/\(func mock\w\+(t \*testing.T\)/\1, fakeServer th.FakeServer/' $(ag 'func mock\w+\(t \*testing.T' -l)
sed -i 's/\(\tmock\w\+(t\)/\1, fakeServer/' $(ag '\tmock\w+\(t' -l)
sed -i 's/\(func Handle\w\+(t \*testing.T\)/\1, fakeServer th.FakeServer/' $(ag 'func Handle\w+\(t \*testing.T' -l)
sed -i 's/\(\tHandle\w\+(t\)/\1, fakeServer/' $(ag '\tHandle\w+\(t' -l)
sed -i 's/\(func handle\w\+(t \*testing.T\)/\1, fakeServer th.FakeServer/' $(ag 'func handle\w+\(t \*testing.T' -l)
sed -i 's/\(\thandle\w\+(t\)/\1, fakeServer/' $(ag '\thandle\w+\(t' -l)
Finally, there were some manual fixes to handle stuff that the regexes
missed.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>1 parent 2f52485 commit eed41cd
File tree
342 files changed
+7196
-7175
lines changed- docs/contributor-tutorial/.template/testing
- openstack
- baremetalintrospection/v1/introspection/testing
- baremetal
- apiversions/testing
- v1
- allocations/testing
- conductors/testing
- drivers/testing
- nodes/testing
- portgroups/testing
- ports/testing
- blockstorage
- apiversions/testing
- v2
- availabilityzones/testing
- backups/testing
- limits/testing
- quotasets/testing
- schedulerstats/testing
- services/testing
- snapshots/testing
- transfers/testing
- volumes/testing
- v3
- attachments/testing
- availabilityzones/testing
- backups/testing
- limits/testing
- qos/testing
- quotasets/testing
- schedulerstats/testing
- services/testing
- snapshots/testing
- transfers/testing
- volumes/testing
- volumetypes/testing
- common/extensions/testing
- compute
- apiversions/testing
- v2
- aggregates/testing
- attachinterfaces/testing
- availabilityzones/testing
- diagnostics/testing
- extensions/testing
- flavors/testing
- hypervisors/testing
- instanceactions/testing
- keypairs/testing
- limits/testing
- quotasets/testing
- remoteconsoles/testing
- secgroups/testing
- servergroups/testing
- servers/testing
- services/testing
- tags/testing
- usage/testing
- volumeattach/testing
- containerinfra
- apiversions/testing
- v1
- certificates/testing
- clusters/testing
- clustertemplates/testing
- nodegroups/testing
- quotas/testing
- container/v1/capsules/testing
- db/v1
- configurations/testing
- databases/testing
- datastores/testing
- flavors/testing
- instances/testing
- quotas/testing
- users/testing
- dns/v2
- recordsets/testing
- transfer
- accept/testing
- request/testing
- zones/testing
- identity
- v2
- extensions/testing
- roles/testing
- tenants/testing
- tokens/testing
- users/testing
- v3
- applicationcredentials/testing
- catalog/testing
- credentials/testing
- domains/testing
- ec2credentials/testing
- ec2tokens/testing
- endpoints/testing
- federation/testing
- groups/testing
- limits/testing
- oauth1/testing
- osinherit/testing
- policies/testing
- projectendpoints/testing
- projects/testing
- regions/testing
- registeredlimits/testing
- roles/testing
- services/testing
- tokens/testing
- trusts/testing
- users/testing
- image/v2
- imagedata/testing
- imageimport/testing
- images/testing
- members/testing
- tasks/testing
- keymanager/v1
- acls/testing
- containers/testing
- orders/testing
- secrets/testing
- loadbalancer/v2
- amphorae/testing
- apiversions/testing
- flavorprofiles/testing
- flavors/testing
- l7policies/testing
- listeners/testing
- loadbalancers/testing
- monitors/testing
- pools/testing
- providers/testing
- quotas/testing
- testhelper
- messaging/v2
- claims/testing
- messages/testing
- queues/testing
- networking/v2
- apiversions/testing
- common
- extensions
- agents/testing
- attributestags/testing
- bgpvpns/testing
- bgp
- peers/testing
- speakers/testing
- dns/testing
- external/testing
- fwaas_v2
- groups/testing
- policies/testing
- rules/testing
- layer3
- addressscopes/testing
- extraroutes/testing
- floatingips/testing
- portforwarding/testing
- routers/testing
- mtu/testing
- networkipavailabilities/testing
- portsbinding/testing
- provider/testing
- qos
- policies/testing
- rules
- testing
- ruletypes/testing
- quotas/testing
- rbacpolicies/testing
- security
- groups/testing
- rules/testing
- subnetpools/testing
- testing
- trunk_details/testing
- trunks/testing
- vlantransparent/testing
- vpnaas
- endpointgroups/testing
- ikepolicies/testing
- ipsecpolicies/testing
- services/testing
- siteconnections/testing
- networks/testing
- ports/testing
- subnets/testing
- objectstorage/v1
- accounts/testing
- containers/testing
- objects/testing
- swauth/testing
- orchestration/v1
- apiversions/testing
- buildinfo/testing
- resourcetypes/testing
- stackevents/testing
- stackresources/testing
- stacks
- testing
- stacktemplates/testing
- placement/v1/resourceproviders/testing
- testing
- utils/testing
- workflow/v2
- crontriggers/testing
- executions/testing
- workflows
- testing
- pagination/testing
- testhelper
- client
- fixture
- testing
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
342 files changed
+7196
-7175
lines changedLines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
| 111 | + | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
| 135 | + | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
154 | | - | |
| 153 | + | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
| 162 | + | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
Lines changed: 16 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
| 141 | + | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
| 164 | + | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
178 | | - | |
| 177 | + | |
| 178 | + | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| |||
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
372 | | - | |
| 371 | + | |
| 372 | + | |
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
385 | | - | |
386 | | - | |
| 385 | + | |
| 386 | + | |
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
397 | | - | |
| 396 | + | |
| 397 | + | |
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
408 | | - | |
| 407 | + | |
| 408 | + | |
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| |||
0 commit comments