Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a814c3b

Browse filesBrowse files
compute: Fix expected and actual test results
Our test convenience function `AssertEquals` accept the expected value first, then the actual value. Many tests in Compute were using it the other way around, thus potentially returning confusing error messages.
1 parent abca462 commit a814c3b
Copy full SHA for a814c3b
Expand file treeCollapse file tree

15 files changed

+115
-115
lines changed

‎internal/acceptance/openstack/compute/v2/attachinterfaces_test.go

Copy file name to clipboardExpand all lines: internal/acceptance/openstack/compute/v2/attachinterfaces_test.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ func TestAttachDetachInterface(t *testing.T) {
4848
}
4949
}
5050

51-
th.AssertEquals(t, found, true)
51+
th.AssertEquals(t, true, found)
5252
}

‎internal/acceptance/openstack/compute/v2/availabilityzones_test.go

Copy file name to clipboardExpand all lines: internal/acceptance/openstack/compute/v2/availabilityzones_test.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestAvailabilityZonesList(t *testing.T) {
3131
}
3232
}
3333

34-
th.AssertEquals(t, found, true)
34+
th.AssertEquals(t, true, found)
3535
}
3636

3737
func TestAvailabilityZonesListDetail(t *testing.T) {
@@ -55,5 +55,5 @@ func TestAvailabilityZonesListDetail(t *testing.T) {
5555
}
5656
}
5757

58-
th.AssertEquals(t, found, true)
58+
th.AssertEquals(t, true, found)
5959
}

‎internal/acceptance/openstack/compute/v2/bootfromvolume_test.go

Copy file name to clipboardExpand all lines: internal/acceptance/openstack/compute/v2/bootfromvolume_test.go
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestBootFromImage(t *testing.T) {
3939

4040
tools.PrintResource(t, server)
4141

42-
th.AssertEquals(t, server.Image["id"], choices.ImageID)
42+
th.AssertEquals(t, choices.ImageID, server.Image["id"])
4343
}
4444

4545
func TestBootFromNewVolume(t *testing.T) {
@@ -80,13 +80,13 @@ func TestBootFromNewVolume(t *testing.T) {
8080
tools.PrintResource(t, server)
8181
tools.PrintResource(t, attachments)
8282
attachmentTag := *attachments[0].Tag
83-
th.AssertEquals(t, attachmentTag, tagName)
83+
th.AssertEquals(t, tagName, attachmentTag)
8484

8585
if server.Image != nil {
8686
t.Fatalf("server image should be nil")
8787
}
8888

89-
th.AssertEquals(t, len(attachments), 1)
89+
th.AssertEquals(t, 1, len(attachments))
9090

9191
// TODO: volumes_attached extension
9292
}
@@ -131,8 +131,8 @@ func TestBootFromExistingVolume(t *testing.T) {
131131
t.Fatalf("server image should be nil")
132132
}
133133

134-
th.AssertEquals(t, len(attachments), 1)
135-
th.AssertEquals(t, attachments[0].VolumeID, volume.ID)
134+
th.AssertEquals(t, 1, len(attachments))
135+
th.AssertEquals(t, volume.ID, attachments[0].VolumeID)
136136
// TODO: volumes_attached extension
137137
}
138138

@@ -218,8 +218,8 @@ func TestAttachNewVolume(t *testing.T) {
218218
tools.PrintResource(t, server)
219219
tools.PrintResource(t, attachments)
220220

221-
th.AssertEquals(t, server.Image["id"], choices.ImageID)
222-
th.AssertEquals(t, len(attachments), 1)
221+
th.AssertEquals(t, choices.ImageID, server.Image["id"])
222+
th.AssertEquals(t, 1, len(attachments))
223223

224224
// TODO: volumes_attached extension
225225
}
@@ -269,9 +269,9 @@ func TestAttachExistingVolume(t *testing.T) {
269269
tools.PrintResource(t, server)
270270
tools.PrintResource(t, attachments)
271271

272-
th.AssertEquals(t, server.Image["id"], choices.ImageID)
273-
th.AssertEquals(t, len(attachments), 1)
274-
th.AssertEquals(t, attachments[0].VolumeID, volume.ID)
272+
th.AssertEquals(t, choices.ImageID, server.Image["id"])
273+
th.AssertEquals(t, 1, len(attachments))
274+
th.AssertEquals(t, volume.ID, attachments[0].VolumeID)
275275

276276
// TODO: volumes_attached extension
277277
}

‎internal/acceptance/openstack/compute/v2/compute.go

Copy file name to clipboardExpand all lines: internal/acceptance/openstack/compute/v2/compute.go
+42-42Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ func CreateAggregate(t *testing.T, client *gophercloud.ServiceClient) (*aggregat
8484
return nil, err
8585
}
8686

87-
th.AssertEquals(t, aggregate.Name, aggregateName)
88-
th.AssertEquals(t, aggregate.AvailabilityZone, availabilityZone)
87+
th.AssertEquals(t, aggregateName, aggregate.Name)
88+
th.AssertEquals(t, availabilityZone, aggregate.AvailabilityZone)
8989

9090
return aggregate, nil
9191
}
@@ -137,7 +137,7 @@ func CreateBootableVolumeServer(t *testing.T, client *gophercloud.ServiceClient,
137137
return nil, err
138138
}
139139

140-
th.AssertEquals(t, newServer.Name, name)
140+
th.AssertEquals(t, name, newServer.Name)
141141

142142
return newServer, nil
143143
}
@@ -169,12 +169,12 @@ func CreateFlavor(t *testing.T, client *gophercloud.ServiceClient) (*flavors.Fla
169169

170170
t.Logf("Successfully created flavor %s", flavor.ID)
171171

172-
th.AssertEquals(t, flavor.Name, flavorName)
173-
th.AssertEquals(t, flavor.RAM, 1)
174-
th.AssertEquals(t, flavor.Disk, 1)
175-
th.AssertEquals(t, flavor.VCPUs, 1)
176-
th.AssertEquals(t, flavor.IsPublic, true)
177-
th.AssertEquals(t, flavor.Description, flavorDescription)
172+
th.AssertEquals(t, flavorName, flavor.Name)
173+
th.AssertEquals(t, 1, flavor.RAM)
174+
th.AssertEquals(t, 1, flavor.Disk)
175+
th.AssertEquals(t, 1, flavor.VCPUs)
176+
th.AssertEquals(t, true, flavor.IsPublic)
177+
th.AssertEquals(t, flavorDescription, flavor.Description)
178178

179179
return flavor, nil
180180
}
@@ -213,7 +213,7 @@ func CreateKeyPair(t *testing.T, client *gophercloud.ServiceClient) (*keypairs.K
213213

214214
t.Logf("Created keypair: %s", keyPairName)
215215

216-
th.AssertEquals(t, keyPair.Name, keyPairName)
216+
th.AssertEquals(t, keyPairName, keyPair.Name)
217217

218218
return keyPair, nil
219219
}
@@ -263,9 +263,9 @@ func CreateMultiEphemeralServer(t *testing.T, client *gophercloud.ServiceClient,
263263
if err != nil {
264264
return server, err
265265
}
266-
th.AssertEquals(t, newServer.Name, name)
267-
th.AssertEquals(t, newServer.Flavor["id"], choices.FlavorID)
268-
th.AssertEquals(t, newServer.Image["id"], choices.ImageID)
266+
th.AssertEquals(t, name, newServer.Name)
267+
th.AssertEquals(t, choices.FlavorID, newServer.Flavor["id"])
268+
th.AssertEquals(t, choices.ImageID, newServer.Image["id"])
269269

270270
return newServer, nil
271271
}
@@ -292,11 +292,11 @@ func CreatePrivateFlavor(t *testing.T, client *gophercloud.ServiceClient) (*flav
292292

293293
t.Logf("Successfully created flavor %s", flavor.ID)
294294

295-
th.AssertEquals(t, flavor.Name, flavorName)
296-
th.AssertEquals(t, flavor.RAM, 1)
297-
th.AssertEquals(t, flavor.Disk, 1)
298-
th.AssertEquals(t, flavor.VCPUs, 1)
299-
th.AssertEquals(t, flavor.IsPublic, false)
295+
th.AssertEquals(t, flavorName, flavor.Name)
296+
th.AssertEquals(t, 1, flavor.RAM)
297+
th.AssertEquals(t, 1, flavor.Disk)
298+
th.AssertEquals(t, 1, flavor.VCPUs)
299+
th.AssertEquals(t, false, flavor.IsPublic)
300300

301301
return flavor, nil
302302
}
@@ -318,7 +318,7 @@ func CreateSecurityGroup(t *testing.T, client *gophercloud.ServiceClient) (*secg
318318

319319
t.Logf("Created security group: %s", securityGroup.ID)
320320

321-
th.AssertEquals(t, securityGroup.Name, name)
321+
th.AssertEquals(t, name, securityGroup.Name)
322322

323323
return securityGroup, nil
324324
}
@@ -344,9 +344,9 @@ func CreateSecurityGroupRule(t *testing.T, client *gophercloud.ServiceClient, se
344344

345345
t.Logf("Created security group rule: %s", rule.ID)
346346

347-
th.AssertEquals(t, rule.FromPort, fromPort)
348-
th.AssertEquals(t, rule.ToPort, toPort)
349-
th.AssertEquals(t, rule.ParentGroupID, securityGroupID)
347+
th.AssertEquals(t, fromPort, rule.FromPort)
348+
th.AssertEquals(t, toPort, rule.ToPort)
349+
th.AssertEquals(t, securityGroupID, rule.ParentGroupID)
350350

351351
return rule, nil
352352
}
@@ -403,9 +403,9 @@ func CreateServer(t *testing.T, client *gophercloud.ServiceClient) (*servers.Ser
403403
return nil, err
404404
}
405405

406-
th.AssertEquals(t, newServer.Name, name)
407-
th.AssertEquals(t, newServer.Flavor["id"], choices.FlavorID)
408-
th.AssertEquals(t, newServer.Image["id"], choices.ImageID)
406+
th.AssertEquals(t, name, newServer.Name)
407+
th.AssertEquals(t, choices.FlavorID, newServer.Flavor["id"])
408+
th.AssertEquals(t, choices.ImageID, newServer.Image["id"])
409409

410410
return newServer, nil
411411
}
@@ -457,8 +457,8 @@ func CreateMicroversionServer(t *testing.T, client *gophercloud.ServiceClient) (
457457
return nil, err
458458
}
459459

460-
th.AssertEquals(t, newServer.Name, name)
461-
th.AssertEquals(t, newServer.Image["id"], choices.ImageID)
460+
th.AssertEquals(t, name, newServer.Name)
461+
th.AssertEquals(t, choices.ImageID, newServer.Image["id"])
462462

463463
return newServer, nil
464464
}
@@ -560,8 +560,8 @@ func CreateServerWithTags(t *testing.T, client *gophercloud.ServiceClient, netwo
560560

561561
newServer, err := res.Extract()
562562
th.AssertNoErr(t, err)
563-
th.AssertEquals(t, newServer.Name, name)
564-
th.AssertDeepEquals(t, *newServer.Tags, []string{"tag1", "tag2"})
563+
th.AssertEquals(t, name, newServer.Name)
564+
th.AssertDeepEquals(t, []string{"tag1", "tag2"}, *newServer.Tags)
565565

566566
return newServer, nil
567567
}
@@ -584,7 +584,7 @@ func CreateServerGroup(t *testing.T, client *gophercloud.ServiceClient, policy s
584584

585585
t.Logf("Successfully created server group %s", name)
586586

587-
th.AssertEquals(t, sg.Name, name)
587+
th.AssertEquals(t, name, sg.Name)
588588

589589
return sg, nil
590590
}
@@ -612,7 +612,7 @@ func CreateServerGroupMicroversion(t *testing.T, client *gophercloud.ServiceClie
612612

613613
t.Logf("Successfully created server group %s", name)
614614

615-
th.AssertEquals(t, sg.Name, name)
615+
th.AssertEquals(t, name, sg.Name)
616616

617617
return sg, nil
618618
}
@@ -662,9 +662,9 @@ func CreateServerInServerGroup(t *testing.T, client *gophercloud.ServiceClient,
662662
return nil, err
663663
}
664664

665-
th.AssertEquals(t, newServer.Name, name)
666-
th.AssertEquals(t, newServer.Flavor["id"], choices.FlavorID)
667-
th.AssertEquals(t, newServer.Image["id"], choices.ImageID)
665+
th.AssertEquals(t, name, newServer.Name)
666+
th.AssertEquals(t, choices.FlavorID, newServer.Flavor["id"])
667+
th.AssertEquals(t, choices.ImageID, newServer.Image["id"])
668668

669669
return newServer, nil
670670
}
@@ -711,9 +711,9 @@ func CreateServerWithPublicKey(t *testing.T, client *gophercloud.ServiceClient,
711711
return nil, err
712712
}
713713

714-
th.AssertEquals(t, newServer.Name, name)
715-
th.AssertEquals(t, newServer.Flavor["id"], choices.FlavorID)
716-
th.AssertEquals(t, newServer.Image["id"], choices.ImageID)
714+
th.AssertEquals(t, name, newServer.Name)
715+
th.AssertEquals(t, choices.FlavorID, newServer.Flavor["id"])
716+
th.AssertEquals(t, choices.ImageID, newServer.Image["id"])
717717

718718
return newServer, nil
719719
}
@@ -910,8 +910,8 @@ func ImportPublicKey(t *testing.T, client *gophercloud.ServiceClient, publicKey
910910

911911
t.Logf("Created keypair: %s", keyPairName)
912912

913-
th.AssertEquals(t, keyPair.Name, keyPairName)
914-
th.AssertEquals(t, keyPair.PublicKey, publicKey)
913+
th.AssertEquals(t, keyPairName, keyPair.Name)
914+
th.AssertEquals(t, publicKey, keyPair.PublicKey)
915915

916916
return keyPair, nil
917917
}
@@ -1070,9 +1070,9 @@ func CreateServerNoNetwork(t *testing.T, client *gophercloud.ServiceClient) (*se
10701070
return nil, err
10711071
}
10721072

1073-
th.AssertEquals(t, newServer.Name, name)
1074-
th.AssertEquals(t, newServer.Flavor["id"], choices.FlavorID)
1075-
th.AssertEquals(t, newServer.Image["id"], choices.ImageID)
1073+
th.AssertEquals(t, name, newServer.Name)
1074+
th.AssertEquals(t, choices.FlavorID, newServer.Flavor["id"])
1075+
th.AssertEquals(t, choices.ImageID, newServer.Image["id"])
10761076

10771077
return newServer, nil
10781078
}

‎internal/acceptance/openstack/compute/v2/extension_test.go

Copy file name to clipboardExpand all lines: internal/acceptance/openstack/compute/v2/extension_test.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestExtensionsList(t *testing.T) {
3131
}
3232
}
3333

34-
th.AssertEquals(t, found, true)
34+
th.AssertEquals(t, true, found)
3535
}
3636

3737
func TestExtensionsGet(t *testing.T) {
@@ -43,5 +43,5 @@ func TestExtensionsGet(t *testing.T) {
4343

4444
tools.PrintResource(t, extension)
4545

46-
th.AssertEquals(t, extension.Name, "AdminActions")
46+
th.AssertEquals(t, "AdminActions", extension.Name)
4747
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.