Help us shape the future of Go! Take the 2026 Go Developer Survey

testing

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

servers unit tests

Index

Constants

View Source
const ConsoleOutputBody = `{
	"output": "abc"
}`
View Source
const FaultyServerBody = `` /* 2179-byte string literal not displayed */

FaultyServerBody is the body of a Get request on an existing server which has a fault/error.

View Source
const ServerListBody = `` /* 5707-byte string literal not displayed */

ServerListBody contains the canned body of a servers.List response.

View Source
const ServerPasswordBody = `` /* 368-byte string literal not displayed */
View Source
const ServerWithTagsCreateRequest = `` /* 147-byte string literal not displayed */
View Source
const SingleServerBody = `` /* 1916-byte string literal not displayed */

SingleServerBody is the canned body of a Get request on an existing server.

View Source
const SingleServerWithTagsBody = `` /* 1942-byte string literal not displayed */

SingleServerWithTagsBody is the canned body of a Get request on an existing server with tags.

Variables

View Source
var (

	// ServerHerp is a Server struct that should correspond to the first result in ServerListBody.
	ServerHerp = servers.Server{
		Status:  "ACTIVE",
		Updated: herpTimeUpdated,
		HostID:  "29d3c8c896a45aa4c34e52247875d7fefc3d94bbcc9f622b5d204362",
		Addresses: map[string]interface{}{
			"private": []interface{}{
				map[string]interface{}{
					"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:7c:1b:2b",
					"version":                 float64(4),
					"addr":                    "10.0.0.32",
					"OS-EXT-IPS:type":         "fixed",
				},
			},
		},
		Links: []interface{}{
			map[string]interface{}{
				"href": "http://104.130.131.164:8774/v2/fcad67a6189847c4aecfa3c81a05783b/servers/ef079b0c-e610-4dfb-b1aa-b49f07ac48e5",
				"rel":  "self",
			},
			map[string]interface{}{
				"href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/servers/ef079b0c-e610-4dfb-b1aa-b49f07ac48e5",
				"rel":  "bookmark",
			},
		},
		Image: map[string]interface{}{
			"id": "f90f6034-2570-4974-8351-6b49732ef2eb",
			"links": []interface{}{
				map[string]interface{}{
					"href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/images/f90f6034-2570-4974-8351-6b49732ef2eb",
					"rel":  "bookmark",
				},
			},
		},
		Flavor: map[string]interface{}{
			"id": "1",
			"links": []interface{}{
				map[string]interface{}{
					"href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/flavors/1",
					"rel":  "bookmark",
				},
			},
		},
		ID:       "ef079b0c-e610-4dfb-b1aa-b49f07ac48e5",
		UserID:   "9349aff8be7545ac9d2f1d00999a23cd",
		Name:     "herp",
		Created:  herpTimeCreated,
		TenantID: "fcad67a6189847c4aecfa3c81a05783b",
		Metadata: map[string]string{},
		AttachedVolumes: []servers.AttachedVolume{
			{
				ID: "2bdbc40f-a277-45d4-94ac-d9881c777d33",
			},
		},
		SecurityGroups: []map[string]interface{}{
			{
				"name": "default",
			},
		},
	}

	// ServerDerp is a Server struct that should correspond to the second server in ServerListBody.
	ServerDerp = servers.Server{
		Status:  "ACTIVE",
		Updated: derpTimeUpdated,
		HostID:  "29d3c8c896a45aa4c34e52247875d7fefc3d94bbcc9f622b5d204362",
		Addresses: map[string]interface{}{
			"private": []interface{}{
				map[string]interface{}{
					"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:9e:89:be",
					"version":                 float64(4),
					"addr":                    "10.0.0.31",
					"OS-EXT-IPS:type":         "fixed",
				},
			},
		},
		Links: []interface{}{
			map[string]interface{}{
				"href": "http://104.130.131.164:8774/v2/fcad67a6189847c4aecfa3c81a05783b/servers/9e5476bd-a4ec-4653-93d6-72c93aa682ba",
				"rel":  "self",
			},
			map[string]interface{}{
				"href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/servers/9e5476bd-a4ec-4653-93d6-72c93aa682ba",
				"rel":  "bookmark",
			},
		},
		Image: map[string]interface{}{
			"id": "f90f6034-2570-4974-8351-6b49732ef2eb",
			"links": []interface{}{
				map[string]interface{}{
					"href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/images/f90f6034-2570-4974-8351-6b49732ef2eb",
					"rel":  "bookmark",
				},
			},
		},
		Flavor: map[string]interface{}{
			"id": "1",
			"links": []interface{}{
				map[string]interface{}{
					"href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/flavors/1",
					"rel":  "bookmark",
				},
			},
		},
		ID:              "9e5476bd-a4ec-4653-93d6-72c93aa682ba",
		UserID:          "9349aff8be7545ac9d2f1d00999a23cd",
		Name:            "derp",
		Created:         derpTimeCreated,
		TenantID:        "fcad67a6189847c4aecfa3c81a05783b",
		Metadata:        map[string]string{},
		AttachedVolumes: []servers.AttachedVolume{},
		SecurityGroups: []map[string]interface{}{
			{
				"name": "default",
			},
		},
	}

	ConsoleOutput = "abc"

	// ServerMerp is a Server struct that should correspond to the second server in ServerListBody.
	ServerMerp = servers.Server{
		Status:  "ACTIVE",
		Updated: merpTimeUpdated,
		HostID:  "29d3c8c896a45aa4c34e52247875d7fefc3d94bbcc9f622b5d204362",
		Addresses: map[string]interface{}{
			"private": []interface{}{
				map[string]interface{}{
					"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:9e:89:be",
					"version":                 float64(4),
					"addr":                    "10.0.0.31",
					"OS-EXT-IPS:type":         "fixed",
				},
			},
		},
		Links: []interface{}{
			map[string]interface{}{
				"href": "http://104.130.131.164:8774/v2/fcad67a6189847c4aecfa3c81a05783b/servers/9e5476bd-a4ec-4653-93d6-72c93aa682ba",
				"rel":  "self",
			},
			map[string]interface{}{
				"href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/servers/9e5476bd-a4ec-4653-93d6-72c93aa682ba",
				"rel":  "bookmark",
			},
		},
		Image: nil,
		Flavor: map[string]interface{}{
			"id": "1",
			"links": []interface{}{
				map[string]interface{}{
					"href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/flavors/1",
					"rel":  "bookmark",
				},
			},
		},
		ID:              "9e5476bd-a4ec-4653-93d6-72c93aa682bb",
		UserID:          "9349aff8be7545ac9d2f1d00999a23cd",
		Name:            "merp",
		Created:         merpTimeCreated,
		TenantID:        "fcad67a6189847c4aecfa3c81a05783b",
		Metadata:        map[string]string{},
		AttachedVolumes: []servers.AttachedVolume{},
		SecurityGroups: []map[string]interface{}{
			{
				"name": "default",
			},
		},
	}

	DerpFault = servers.Fault{
		Code:    500,
		Created: faultTimeCreated,
		Details: "Stock details for test",
		Message: "Conflict updating instance c2ce4dea-b73f-4d01-8633-2c6032869281. " +
			"Expected: {'task_state': [u'spawning']}. Actual: {'task_state': None}",
	}
)
View Source
var ListAddressesExpected = map[string][]servers.Address{
	"public": {
		{
			Version: 4,
			Address: "50.56.176.35",
		},
		{
			Version: 6,
			Address: "2001:4800:790e:510:be76:4eff:fe04:84a8",
		},
	},
	"private": {
		{
			Version: 4,
			Address: "10.180.3.155",
		},
	},
}

ListAddressesExpected represents an expected repsonse from a ListAddresses request.

View Source
var ListNetworkAddressesExpected = []servers.Address{
	{
		Version: 4,
		Address: "50.56.176.35",
	},
	{
		Version: 6,
		Address: "2001:4800:790e:510:be76:4eff:fe04:84a8",
	},
}

ListNetworkAddressesExpected represents an expected repsonse from a ListAddressesByNetwork request.

Functions

func HandleAddressListSuccessfully

func HandleAddressListSuccessfully(t *testing.T)

HandleAddressListSuccessfully sets up the test server to respond to a ListAddresses request.

func HandleAdminPasswordChangeSuccessfully

func HandleAdminPasswordChangeSuccessfully(t *testing.T)

HandleAdminPasswordChangeSuccessfully sets up the test server to respond to a server password change request.

func HandleCreateServerImageSuccessfully

func HandleCreateServerImageSuccessfully(t *testing.T)

HandleCreateServerImageSuccessfully sets up the test server to respond to a TestCreateServerImage request.

func HandleMetadataGetSuccessfully

func HandleMetadataGetSuccessfully(t *testing.T)

HandleMetadataGetSuccessfully sets up the test server to respond to a metadata Get request.

func HandleMetadataResetSuccessfully

func HandleMetadataResetSuccessfully(t *testing.T)

HandleMetadataResetSuccessfully sets up the test server to respond to a metadata Create request.

func HandleMetadataUpdateSuccessfully

func HandleMetadataUpdateSuccessfully(t *testing.T)

HandleMetadataUpdateSuccessfully sets up the test server to respond to a metadata Update request.

func HandleMetadatumCreateSuccessfully

func HandleMetadatumCreateSuccessfully(t *testing.T)

HandleMetadatumCreateSuccessfully sets up the test server to respond to a metadatum Create request.

func HandleMetadatumDeleteSuccessfully

func HandleMetadatumDeleteSuccessfully(t *testing.T)

HandleMetadatumDeleteSuccessfully sets up the test server to respond to a metadatum Delete request.

func HandleMetadatumGetSuccessfully

func HandleMetadatumGetSuccessfully(t *testing.T)

HandleMetadatumGetSuccessfully sets up the test server to respond to a metadatum Get request.

func HandleNetworkAddressListSuccessfully

func HandleNetworkAddressListSuccessfully(t *testing.T)

HandleNetworkAddressListSuccessfully sets up the test server to respond to a ListAddressesByNetwork request.

func HandlePasswordGetSuccessfully

func HandlePasswordGetSuccessfully(t *testing.T)

HandlePasswordGetSuccessfully sets up the test server to respond to a password Get request.

func HandleRebootSuccessfully

func HandleRebootSuccessfully(t *testing.T)

HandleRebootSuccessfully sets up the test server to respond to a reboot request with success.

func HandleRebuildSuccessfully

func HandleRebuildSuccessfully(t *testing.T, response string)

HandleRebuildSuccessfully sets up the test server to respond to a rebuild request with success.

func HandleServerCreationSuccessfully

func HandleServerCreationSuccessfully(t *testing.T, response string)

HandleServerCreationSuccessfully sets up the test server to respond to a server creation request with a given response.

func HandleServerCreationWithCustomFieldSuccessfully

func HandleServerCreationWithCustomFieldSuccessfully(t *testing.T, response string)

HandleServerCreationWithCustomFieldSuccessfully sets up the test server to respond to a server creation request with a given response.

func HandleServerCreationWithMetadata

func HandleServerCreationWithMetadata(t *testing.T, response string)

HandleServerCreationWithMetadata sets up the test server to respond to a server creation request with a given response.

func HandleServerCreationWithUserdata

func HandleServerCreationWithUserdata(t *testing.T, response string)

HandleServerCreationWithUserdata sets up the test server to respond to a server creation request with a given response.

func HandleServerDeletionSuccessfully

func HandleServerDeletionSuccessfully(t *testing.T)

HandleServerDeletionSuccessfully sets up the test server to respond to a server deletion request.

func HandleServerForceDeletionSuccessfully

func HandleServerForceDeletionSuccessfully(t *testing.T)

HandleServerForceDeletionSuccessfully sets up the test server to respond to a server force deletion request.

func HandleServerGetFaultSuccessfully

func HandleServerGetFaultSuccessfully(t *testing.T)

HandleServerGetFaultSuccessfully sets up the test server to respond to a server Get request which contains a fault.

func HandleServerGetSuccessfully

func HandleServerGetSuccessfully(t *testing.T)

HandleServerGetSuccessfully sets up the test server to respond to a server Get request.

func HandleServerListSuccessfully

func HandleServerListSuccessfully(t *testing.T)

HandleServerListSuccessfully sets up the test server to respond to a server List request.

func HandleServerNoNetworkCreationSuccessfully

func HandleServerNoNetworkCreationSuccessfully(t *testing.T, response string)

HandleServerNoNetworkCreationSuccessfully sets up the test server with no network to respond to a server creation request with a given response.

func HandleServerUpdateSuccessfully

func HandleServerUpdateSuccessfully(t *testing.T)

HandleServerUpdateSuccessfully sets up the test server to respond to a server Update request.

func HandleServerWithTagsCreationSuccessfully

func HandleServerWithTagsCreationSuccessfully(t *testing.T)

HandleServerWithTagsCreationSuccessfully sets up the test server to respond to a server creation request with a given response.

func HandleServersCreationSuccessfully

func HandleServersCreationSuccessfully(t *testing.T, response string)

HandleServerCreationWithCustomFieldSuccessfully sets up the test server to respond to a server creation request with a given response.

func HandleShowConsoleOutputSuccessfully

func HandleShowConsoleOutputSuccessfully(t *testing.T, response string)

HandleShowConsoleOutputSuccessfully sets up the test server to respond to a os-getConsoleOutput request with success.

Types

type CreateOptsWithCustomField

type CreateOptsWithCustomField struct {
	servers.CreateOpts
	Foo string `json:"foo,omitempty"`
}

func (CreateOptsWithCustomField) ToServerCreateMap

func (opts CreateOptsWithCustomField) ToServerCreateMap() (map[string]interface{}, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL