testing

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

zones unit tests

Index

Constants

This section is empty.

Variables

View Source
var CreateZoneRequest = fmt.Sprintf(`{
    "description": "%s",
    "email": "joe@example.org",
    "name": "%s",
    "ttl": 7200,
    "type": "PRIMARY"
}`,
	descriptionZone1,
	nameZone1,
)

CreateZoneRequest is a sample request to create a zone.

View Source
var CreateZoneResponse = fmt.Sprintf(`{
	"id": "%s",
	"name": "%s",
	"description": "%s",
	"project_id": "%s",
	"pool_id": "",
	"email": "",
	"ttl": 0,
	"serial": 0,
	"status": "CREATING",
	"masters": [],
	"type": "",
	"transferred_at": null,
	"version": 1,
	"created_at": "%s",
	"updated_at": null,
	"links": {
		"self": "dummylink"
	}
}`, idZone1,
	nameZone1,
	descriptionZone1,
	tenantID,
	zoneCreatedAt,
)

CreateZoneResponse is a sample response to a create request.

View Source
var CreatedZone = zones.Zone{
	ID:            idZone1,
	Name:          nameZone1,
	Description:   descriptionZone1,
	ProjectID:     tenantID,
	PoolID:        "",
	Email:         "",
	TTL:           0,
	Serial:        0,
	Status:        "CREATING",
	Masters:       []string{},
	Type:          "",
	TransferredAt: time.Time{},
	Version:       1,
	CreatedAt:     ZoneCreatedAt,
	UpdatedAt:     time.Time{},

	Links: map[string]interface{}{
		"self": "dummylink",
	},
}

CreatedZone is the expected created zone

View Source
var ExpectedZonesSlice = []zones.Zone{FirstZone, SecondZone}

ExpectedZonesSlice is the slice of results that should be parsed from ListOutput, in the expected order.

View Source
var FirstZone = zones.Zone{
	ID:            idZone1,
	PoolID:        "",
	ProjectID:     tenantID,
	Name:          nameZone1,
	Email:         "",
	TTL:           0,
	Serial:        0,
	Status:        "ACTIVE",
	Description:   descriptionZone1,
	Masters:       []string{},
	Type:          "",
	TransferredAt: time.Time{},
	Version:       1,
	CreatedAt:     ZoneCreatedAt,
	UpdatedAt:     ZoneUpdatedAt,
	Action:        "",
	Attributes:    []string{},
	Links: map[string]interface{}{
		"self": "dummylink",
	},
}

FirstZone is the mock object of expected zone-1

View Source
var GetResponse = fmt.Sprintf(`
{
	"id": "%s",
	"name": "%s",
	"description": "%s",
	"project_id": "%s",
	"pool_id": "",
	"email": "",
	"ttl": 0,
	"serial": 0,
	"status": "ACTIVE",
	"masters": [],
	"type": "",
	"transferred_at": null,
	"version": 1,
	"created_at": "%s",
	"updated_at": "%s",
	"links": {
		"self": "dummylink"
	}
}`, idZone1,
	nameZone1,
	descriptionZone1,
	tenantID,
	zoneCreatedAt,
	zoneUpdatedAt,
)

GetResponse is a sample response to a Get call. This get result does not have action, attributes in ECL2.0

View Source
var GetResponseStruct = zones.Zone{
	ID:            idZone1,
	PoolID:        "",
	ProjectID:     tenantID,
	Name:          nameZone1,
	Email:         "",
	TTL:           0,
	Serial:        0,
	Status:        "ACTIVE",
	Description:   descriptionZone1,
	Masters:       []string{},
	Type:          "",
	TransferredAt: time.Time{},
	Version:       1,
	CreatedAt:     ZoneCreatedAt,
	UpdatedAt:     ZoneUpdatedAt,
	Action:        "",
	Links: map[string]interface{}{
		"self": "dummylink",
	},
}

GetResponseStruct mocked actual

View Source
var ListResponse = fmt.Sprintf(`
{
	"api_result": "success",
	"zones": [{
		"id": "%s",
		"description": "%s",
		"project_id": "%s",
		"created_at": "%s",
		"updated_at": "%s",
		"name": "%s",
		"pool_id": "",
		"email": "",
		"ttl": 0,
		"serial": 0,
		"status": "ACTIVE",
		"masters": [],
		"type": "",
		"transferred_at": null,
		"version": 1,
		"links": {
			"self": "dummylink"
		},
		"action": "",
		"attributes": []
	}, {
		"id": "%s",
		"description": "This is my zone 2",
		"project_id": "%s",
		"created_at": "%s",
		"updated_at": "%s",
		"name": "myzone2.com.",
		"pool_id": "",
		"email": "",
		"ttl": 0,
		"serial": 0,
		"status": "ACTIVE",
		"masters": [],
		"type": "",
		"transferred_at": null,
		"version": 1,
		"links": {
			"self": "dummylink"
		},
		"action": "",
		"attributes": []
	}],
	"links": {
		"self": "dummylink"
	},
	"metadata": {
		"total_count": 2
	}
}`,

	idZone1,
	descriptionZone1,
	tenantID,
	zoneCreatedAt,
	zoneUpdatedAt,
	nameZone1,

	idZone2,
	tenantID,
	zoneCreatedAt,
	zoneUpdatedAt,
)

ListResponse is a sample response to a List call.

View Source
var SecondZone = zones.Zone{
	ID:            idZone2,
	PoolID:        "",
	ProjectID:     tenantID,
	Name:          "myzone2.com.",
	Email:         "",
	TTL:           0,
	Serial:        0,
	Status:        "ACTIVE",
	Description:   "This is my zone 2",
	Masters:       []string{},
	Type:          "",
	TransferredAt: time.Time{},
	Version:       1,
	CreatedAt:     ZoneCreatedAt,
	UpdatedAt:     ZoneUpdatedAt,
	Action:        "",
	Attributes:    []string{},
	Links: map[string]interface{}{
		"self": "dummylink",
	}}

SecondZone is the mock object of expected zone-2

View Source
var UpdateZoneRequest = fmt.Sprintf(`
{
    "ttl": 600,
	"description": "%s",
	"masters": [],
	"email": ""
}`,
	descriptionZone1Update,
)

UpdateZoneRequest is a sample request to update a zone.

View Source
var UpdateZoneResponse = fmt.Sprintf(`{
	"id": "%s",
	"name": "%s",
	"description": "%s",
	"project_id": "%s",
	"pool_id": "",
	"email": "",
	"ttl": 0,
	"serial": 0,
	"status": "ACTIVE",
	"masters": [],
	"type": "",
	"transferred_at": null,
	"version": 1,
	"created_at": "%s",
	"updated_at": "%s",
	"links": {
		"self": "dummylink"
	}
}`, idZone1,
	nameZone1,
	descriptionZone1Update,
	tenantID,
	zoneCreatedAt,
	zoneUpdatedAt,
)

UpdateZoneResponse is a sample response to update a zone.

View Source
var UpdatedZone = zones.Zone{
	ID:            idZone1,
	Name:          nameZone1,
	Description:   descriptionZone1Update,
	ProjectID:     tenantID,
	PoolID:        "",
	Email:         "",
	TTL:           0,
	Serial:        0,
	Status:        "ACTIVE",
	Masters:       []string{},
	Type:          "",
	TransferredAt: time.Time{},
	Version:       1,
	CreatedAt:     ZoneCreatedAt,
	UpdatedAt:     ZoneUpdatedAt,

	Links: map[string]interface{}{
		"self": "dummylink",
	},
}

UpdatedZone is the expected updated zone

View Source
var ZoneCreatedAt, _ = time.Parse(eclcloud.RFC3339MilliNoZ, zoneCreatedAt)

ZoneCreatedAt is parsed zone creation time

View Source
var ZoneUpdatedAt, _ = time.Parse(eclcloud.RFC3339MilliNoZ, zoneUpdatedAt)

ZoneUpdatedAt is parsed zone update time

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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