// CreateShareNetwork will create a share network with a random name. An // error will be returned if the share network was unable to be created. func CreateShareNetwork(t *testing.T, client *gophercloud.ServiceClient) (*sharenetworks.ShareNetwork, error) { if testing.Short() { t.Skip("Skipping test that requires share network creation in short mode.") } shareNetworkName := tools.RandomString("ACPTTEST", 16) t.Logf("Attempting to create share network: %s", shareNetworkName) createOpts := sharenetworks.CreateOpts{ Name: shareNetworkName, Description: "This is a shared network", } shareNetwork, err := sharenetworks.Create(client, createOpts).Extract() if err != nil { return shareNetwork, err } return shareNetwork, nil }
// Verifies that a share network can be created correctly func TestCreate(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP() MockCreateResponse(t) options := &sharenetworks.CreateOpts{ Name: "my_network", Description: "This is my share network", NeutronNetID: "998b42ee-2cee-4d36-8b95-67b5ca1f2109", NeutronSubnetID: "53482b62-2c84-4a53-b6ab-30d9d9800d06", } n, err := sharenetworks.Create(client.ServiceClient(), options).Extract() th.AssertNoErr(t, err) th.AssertEquals(t, n.Name, "my_network") th.AssertEquals(t, n.Description, "This is my share network") th.AssertEquals(t, n.NeutronNetID, "998b42ee-2cee-4d36-8b95-67b5ca1f2109") th.AssertEquals(t, n.NeutronSubnetID, "53482b62-2c84-4a53-b6ab-30d9d9800d06") }