testing

package
v2.1.0 Latest Latest
Warning

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

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

Documentation

Overview

recordsets unit tests

Index

Constants

View Source
const TTLRecordSet1 = 3000
View Source
const TTLRecordSet1Update = 3600

Variables

View Source
var CreateRequest = fmt.Sprintf(`{
    "name" : "%s",
    "description" : "%s",
    "type" : "A",
    "ttl" : %d,
    "records" : ["%s"]
}`,
	nameRecordSet1,
	descriptionRecordSet1,
	TTLRecordSet1,
	ipRecordSet1,
)

CreateRequest is a sample request to create a resource record.

View Source
var CreateResponse = fmt.Sprintf(`{
	"recordsets": [{
		"id": "%s",
		"zone_id": "%s",
		"records": ["%s"],
		"ttl": %d,
		"name": "%s",
		"description": "%s",
		"type": "A",
		"version": 1,
		"created_at": "",
		"updated_at": null,
		"links": {
			"self": "dummylink"
		}
	}],
	"links": {
		"self": "dummylink"
	},
	"metadata": {
		"total_count": 1
	}
}`, idRecordSet1,
	idZone,
	ipRecordSet1,
	TTLRecordSet1,
	nameRecordSet1,
	descriptionRecordSet1,
)

CreateResponse is a sample response to a create request.

ExpectedRecordSetSlice is the slice of results that should be parsed from ListByZoneOutput, in the expected order.

View Source
var ExpectedRecordSetSliceLimited = []recordsets.RecordSet{SecondRecordSet}

ExpectedRecordSetSliceLimited is the slice of limited results that should be parsed from ListByZoneOutput.

View Source
var FirstRecordSet = recordsets.RecordSet{
	ID:          idRecordSet1,
	Description: descriptionRecordSet1,
	Records:     []string{ipRecordSet1},
	TTL:         TTLRecordSet1,
	Name:        nameRecordSet1,
	ZoneID:      idZone,
	CreatedAt:   RecordSetCreatedAt,
	UpdatedAt:   RecordSetUpdatedAt,
	Version:     1,
	Type:        "A",
	Status:      "ACTIVE",
	Action:      "",
	Links: []eclcloud.Link{
		{
			Rel:  "self",
			Href: "dummylink",
		},
	},
}

FirstRecordSet is initialized struct as actual response

View Source
var GetResponse = fmt.Sprintf(`{
	"id": "%s",
	"name": "%s",
	"ttl": %d,
	"description": "%s",
	"records": ["%s"],
	"type": "A",
	"version": 1,
	"created_at": "%s",
	"updated_at": "%s",
	"zone_id": "%s",
	"status": "ACTIVE",
	"links": {
		"self": "dummylink"
    }
}`,
	idRecordSet1,
	nameRecordSet1,
	TTLRecordSet1,
	descriptionRecordSet1,
	ipRecordSet1,
	recordSetCreatedAt,
	recordSetUpdatedAt,
	idZone,
)

GetResponse is a sample response to a Get call.

View Source
var ListResponse = fmt.Sprintf(`{
	"recordsets": [{
		"id": "%s",
		"action": "",
		"name": "%s",
		"ttl": %d,
		"description": "%s",
		"records": ["%s"],
		"type": "A",
		"version": 1,
		"status": "ACTIVE",
		"created_at": "%s",
		"updated_at": "%s",
		"zone_id": "%s",
		"links": {
			"self": "dummylink"
		}
	}, {
		"id": "%s",
		"action": "",
		"name": "rs2.zone1.com.",
		"ttl": 3000,
		"description": "a record set 2",
		"records": ["20.1.0.0"],
		"type": "A",
		"version": 1,
		"status": "ACTIVE",
		"created_at": "%s",
		"updated_at": "%s",
		"zone_id": "%s",
		"links": {
			"self": "dummylink"
		}
	}],
	"links": {
        "self": "dummylink"
	},
	"metadata": {
		"total_count": 2
	}
}`,

	idRecordSet1,
	nameRecordSet1,
	TTLRecordSet1,
	descriptionRecordSet1,
	ipRecordSet1,
	recordSetCreatedAt,
	recordSetUpdatedAt,
	idZone,

	idRecordSet2,
	recordSetCreatedAt,
	recordSetUpdatedAt,
	idZone,
)

ListResponse is a sample response to a TestListDNSRecordSet call.

View Source
var ListResponseLimited = fmt.Sprintf(`{
	"recordsets": [{
		"id": "%s",
		"action": "",
		"name": "rs2.zone1.com.",
		"ttl": 3000,
		"description": "a record set 2",
		"records": ["20.1.0.0"],
		"type": "A",
		"version": 1,
		"status": "ACTIVE",
		"created_at": "%s",
		"updated_at": "%s",
		"zone_id": "%s",
		"links": {
			"self": "dummylink"
		}
	}],
	"links": {
        "self": "dummylink"
	},
	"metadata": {
		"total_count": 1
	}
}`,
	idRecordSet2,
	recordSetCreatedAt,
	recordSetUpdatedAt,
	idZone,
)

ListResponseLimited is a sample response with limit query option.

View Source
var NextPageRequest = fmt.Sprintf(`
{
  "links": {
    "self": "%s",
    "next": "%s"
  }
}`, selfURL, nextURL)

NextPageRequest is a sample request to test pagination.

View Source
var RecordSetCreatedAt, _ = time.Parse(eclcloud.RFC3339MilliNoZ, recordSetCreatedAt)

RecordSetCreatedAt is mocked created time of each records.

View Source
var RecordSetUpdatedAt, _ = time.Parse(eclcloud.RFC3339MilliNoZ, recordSetUpdatedAt)

RecordSetUpdatedAt is mocked updated time of each records.

View Source
var SecondRecordSet = recordsets.RecordSet{
	ID:          idRecordSet2,
	Description: "a record set 2",
	Records:     []string{"20.1.0.0"},
	TTL:         3000,
	Name:        "rs2.zone1.com.",
	ZoneID:      idZone,
	CreatedAt:   RecordSetCreatedAt,
	UpdatedAt:   RecordSetUpdatedAt,
	Version:     1,
	Type:        "A",
	Status:      "ACTIVE",
	Action:      "",
	Links: []eclcloud.Link{
		{
			Rel:  "self",
			Href: "dummylink",
		},
	},
}

SecondRecordSet is initialized struct as actual response

View Source
var UpdateRequest = fmt.Sprintf(`{
    "name": "%s",
    "description" : "%s",
    "ttl" : %d,
    "records" : ["%s"]
}`,
	nameRecordSet1Update,
	descriptionRecordSet1Update,
	TTLRecordSet1Update,
	ipRecordSet1Update,
)

UpdateRequest is a sample request to update a record set.

View Source
var UpdateResponse = fmt.Sprintf(`{
	"id": "%s",
	"name": "%s",
	"ttl": %d,
	"description": "%s",
	"records": "%s",
	"type": "A",
	"version": 1,
	"created_at": null,
	"updated_at": null,
	"zone_id": "%s",
	"links": {
		"self": "dummylink"
	} 
}`,
	idRecordSet1,
	nameRecordSet1Update,
	TTLRecordSet1Update,
	descriptionRecordSet1Update,
	ipRecordSet1Update,
	idZone,
)

UpdateResponse is a sample response to an update request.

View Source
var UpdatedRecordSet = recordsets.RecordSet{
	ID:          idRecordSet1,
	Name:        nameRecordSet1Update,
	TTL:         TTLRecordSet1Update,
	Description: descriptionRecordSet1Update,
	Records:     ipRecordSet1Update,
	Type:        "A",
	Version:     1,
	CreatedAt:   time.Time{},
	UpdatedAt:   time.Time{},
	ZoneID:      idZone,

	Links: []eclcloud.Link{
		{
			Rel:  "self",
			Href: "dummylink",
		},
	},
}

UpdatedRecordSet is initialized struct as actual response of update

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