55 "net/http"
66 "testing"
77
8- "github.com/gophercloud/gophercloud"
98 fake "github.com/gophercloud/gophercloud/openstack/networking/v2/common"
109 "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/provider"
1110 "github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
@@ -27,39 +26,21 @@ func TestList(t *testing.T) {
2726 fmt .Fprintf (w , nettest .ListResponse )
2827 })
2928
30- /* NOTE(jtopjian): This does not work
29+ allPages , err := networks .List (fake .ServiceClient (), networks.ListOpts {}).AllPages ()
30+ th .AssertNoErr (t , err )
31+
3132 type NetworkWithExt struct {
3233 networks.Network
3334 provider.NetworkProviderExt
3435 }
3536 var actual []NetworkWithExt
3637 err = networks .ExtractNetworksInto (allPages , & actual )
37- */
38-
39- /* NOTE(jtopjian):
40- If you add networks.Network as an embedded/anonymous struct
41- to NetworkProviderExt in results.go, then everything is unmarshalled fine.
42- But if networks.Networks ever had to implement UnmarshalJSON, I'm not sure
43- what the result would be.
44-
45- var actual []provider.NetworkPRoviderExt // with embedded networks.Network
46- err = networks.ExtractNetworksInto(allPages, &actual)
47- */
48-
49- var actualNetwork []networks.Network
50- var actualNetworkExt []provider.NetworkProviderExt
51-
52- allPages , err := networks .List (fake .ServiceClient (), networks.ListOpts {}).AllPages ()
53- th .AssertNoErr (t , err )
54-
55- err = networks .ExtractNetworksInto (allPages , & actualNetwork )
56- err = networks .ExtractNetworksInto (allPages , & actualNetworkExt )
5738 th .AssertNoErr (t , err )
5839
59- th .AssertEquals (t , "d32019d3-bc6e-4319-9c1d-6722fc136a22" , actualNetwork [0 ].ID )
60- th .AssertEquals (t , "db193ab3-96e3-4cb3-8fc5-05f4296d0324" , actualNetwork [1 ].ID )
61- th .AssertEquals (t , "local" , actualNetworkExt [1 ].NetworkType )
62- th .AssertEquals (t , "1234567890" , actualNetworkExt [1 ].SegmentationID )
40+ th .CheckEquals (t , "d32019d3-bc6e-4319-9c1d-6722fc136a22" , actual [0 ].ID )
41+ th .CheckEquals (t , "db193ab3-96e3-4cb3-8fc5-05f4296d0324" , actual [1 ].ID )
42+ th .CheckEquals (t , "local" , actual [1 ].NetworkType )
43+ th .CheckEquals (t , "1234567890" , actual [1 ].SegmentationID )
6344}
6445
6546func TestGet (t * testing.T ) {
@@ -84,12 +65,13 @@ func TestGet(t *testing.T) {
8465 err := networks .Get (fake .ServiceClient (), "d32019d3-bc6e-4319-9c1d-6722fc136a22" ).ExtractInto (& s )
8566 th .AssertNoErr (t , err )
8667
87- th .AssertEquals (t , "d32019d3-bc6e-4319-9c1d-6722fc136a22" , s .ID )
88- th .AssertEquals (t , "" , s .PhysicalNetwork )
89- th .AssertEquals (t , "local" , s .NetworkType )
90- th .AssertEquals (t , "9876543210" , s .SegmentationID )
68+ th .CheckEquals (t , "d32019d3-bc6e-4319-9c1d-6722fc136a22" , s .ID )
69+ th .CheckEquals (t , "" , s .PhysicalNetwork )
70+ th .CheckEquals (t , "local" , s .NetworkType )
71+ th .CheckEquals (t , "9876543210" , s .SegmentationID )
9172}
9273
74+ /*
9375func TestCreate(t *testing.T) {
9476 th.SetupHTTP()
9577 defer th.TeardownHTTP()
@@ -154,3 +136,4 @@ func TestUpdate(t *testing.T) {
154136 th.AssertEquals(t, "local", s.NetworkType)
155137 th.AssertEquals(t, "1234567890", s.SegmentationID)
156138}
139+ */
0 commit comments