Documentation ¶
Index ¶
- type InspectorMock
- func (m *InspectorMock) Endpoint() string
- func (m *InspectorMock) NotReady(errorCode int) *InspectorMock
- func (m *InspectorMock) Ready() *InspectorMock
- func (m *InspectorMock) WithIntrospection(nodeUUID string, status introspection.Introspection) *InspectorMock
- func (m *InspectorMock) WithIntrospectionData(nodeUUID string, data introspection.Data) *InspectorMock
- func (m *InspectorMock) WithIntrospectionDataFailed(nodeUUID string, errorCode int) *InspectorMock
- func (m *InspectorMock) WithIntrospectionFailed(nodeUUID string, errorCode int) *InspectorMock
- type IronicMock
- func (m *IronicMock) BIOSDetailSettings(nodeUUID string) *IronicMock
- func (m *IronicMock) BIOSSettings(nodeUUID string) *IronicMock
- func (m *IronicMock) ClearDatabase()
- func (m *IronicMock) CreateNodes(callback NodeCreateCallback) *IronicMock
- func (m *IronicMock) Delete(id string) *IronicMock
- func (m *IronicMock) DeleteError(id string, errorCode int) *IronicMock
- func (m *IronicMock) Endpoint() string
- func (m *IronicMock) GetLastNodeUpdateRequestFor(id string) (updates []nodes.UpdateOperation)
- func (m *IronicMock) NoBIOS(nodeUUID string) *IronicMock
- func (m *IronicMock) NoNode(name string) *IronicMock
- func (m *IronicMock) Node(node nodes.Node) *IronicMock
- func (m *IronicMock) NodeError(name string, errorCode int) *IronicMock
- func (m *IronicMock) NodeUpdate(node nodes.Node) *IronicMock
- func (m *IronicMock) NodeUpdateError(id string, errorCode int) *IronicMock
- func (m *IronicMock) Nodes(allNodes []nodes.Node) *IronicMock
- func (m *IronicMock) NotReady(errorCode int) *IronicMock
- func (m *IronicMock) Port(port ports.Port) *IronicMock
- func (m *IronicMock) Ready() *IronicMock
- func (m *IronicMock) WithDefaultResponses() *IronicMock
- func (m *IronicMock) WithDrivers() *IronicMock
- func (m *IronicMock) WithNodeStatesPower(nodeUUID string, code int) *IronicMock
- func (m *IronicMock) WithNodeStatesPowerUpdate(nodeUUID string, code int) *IronicMock
- func (m *IronicMock) WithNodeStatesProvision(nodeUUID string) *IronicMock
- func (m *IronicMock) WithNodeStatesProvisionUpdate(nodeUUID string) *IronicMock
- func (m *IronicMock) WithNodeValidate(nodeUUID string) *IronicMock
- type MockServer
- func (m *MockServer) AddDefaultResponse(patternWithVars string, httpMethod string, code int, payload string) *MockServer
- func (m *MockServer) AddDefaultResponseJSON(patternWithVars string, httpMethod string, code int, payload interface{}) *MockServer
- func (m *MockServer) Endpoint() string
- func (m *MockServer) ErrorResponse(pattern string, errorCode int) *MockServer
- func (m *MockServer) GetLastRequestFor(pattern string, method string) (string, bool)
- func (m *MockServer) Handler(pattern string, handlerFunc http.HandlerFunc) *MockServer
- func (m *MockServer) ResponseJSON(pattern string, payload interface{}) *MockServer
- func (m *MockServer) ResponseWithCode(patternWithMethod string, payload string, code int) *MockServer
- func (m *MockServer) SendJSONResponse(payload interface{}, code int, w http.ResponseWriter, r *http.Request)
- func (m *MockServer) Start() *MockServer
- func (m *MockServer) Stop()
- type NodeCreateCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InspectorMock ¶
type InspectorMock struct {
*MockServer
}
InspectorMock is a test server that implements Ironic Inspector's semantics
func NewInspector ¶
func NewInspector(t *testing.T) *InspectorMock
NewInspector builds a new inspector mock server
func (*InspectorMock) Endpoint ¶
func (m *InspectorMock) Endpoint() string
Endpoint returns the URL to the server
func (*InspectorMock) NotReady ¶
func (m *InspectorMock) NotReady(errorCode int) *InspectorMock
NotReady configures the server with an error response for /v1
func (*InspectorMock) Ready ¶
func (m *InspectorMock) Ready() *InspectorMock
Ready configures the server with a valid response for /v1
func (*InspectorMock) WithIntrospection ¶
func (m *InspectorMock) WithIntrospection(nodeUUID string, status introspection.Introspection) *InspectorMock
WithIntrospection configures the server with a valid response for /v1/introspection/<node>
func (*InspectorMock) WithIntrospectionData ¶
func (m *InspectorMock) WithIntrospectionData(nodeUUID string, data introspection.Data) *InspectorMock
WithIntrospectionData configures the server with a valid response for /v1/introspection/<node>/data
func (*InspectorMock) WithIntrospectionDataFailed ¶
func (m *InspectorMock) WithIntrospectionDataFailed(nodeUUID string, errorCode int) *InspectorMock
WithIntrospectionDataFailed configures the server with an error response for /v1/introspection/<node>/data
func (*InspectorMock) WithIntrospectionFailed ¶
func (m *InspectorMock) WithIntrospectionFailed(nodeUUID string, errorCode int) *InspectorMock
WithIntrospectionFailed configures the server with an error response for /v1/introspection/<node>
type IronicMock ¶
type IronicMock struct { *MockServer CreatedNodes int }
IronicMock is a test server that implements Ironic's semantics
func (*IronicMock) BIOSDetailSettings ¶
func (m *IronicMock) BIOSDetailSettings(nodeUUID string) *IronicMock
BIOSDetailSettings configure the server with a valid response for /v1/nodes/<node>/bios?detail=True
func (*IronicMock) BIOSSettings ¶
func (m *IronicMock) BIOSSettings(nodeUUID string) *IronicMock
BIOSSettings configure the server with a valid response for /v1/nodes/<node>/bios
func (*IronicMock) ClearDatabase ¶
func (m *IronicMock) ClearDatabase()
ClearDatabase simulates the loss of the Ironic database
Database clearing is simulated by setting all registered non-POST handlers to return a 404 error. Both regular handlers, and default handlers are affected.
func (*IronicMock) CreateNodes ¶
func (m *IronicMock) CreateNodes(callback NodeCreateCallback) *IronicMock
CreateNodes configures the server so POSTing to /v1/nodes saves the data
func (*IronicMock) Delete ¶
func (m *IronicMock) Delete(id string) *IronicMock
Delete configures the server with a valid response for [DELETE] /v1/nodes/ on the specific node id
func (*IronicMock) DeleteError ¶
func (m *IronicMock) DeleteError(id string, errorCode int) *IronicMock
DeleteError configures the server with an error response for [DELETE] /v1/nodes/
func (*IronicMock) Endpoint ¶
func (m *IronicMock) Endpoint() string
Endpoint returns the URL for accessing the server
func (*IronicMock) GetLastNodeUpdateRequestFor ¶
func (m *IronicMock) GetLastNodeUpdateRequestFor(id string) (updates []nodes.UpdateOperation)
GetLastNodeUpdateRequestFor returns the content of the last update request for the specified node
func (*IronicMock) NoBIOS ¶
func (m *IronicMock) NoBIOS(nodeUUID string) *IronicMock
NoBIOS configures the server so /v1/node/<node>/bios returns a 404
func (*IronicMock) NoNode ¶
func (m *IronicMock) NoNode(name string) *IronicMock
NoNode configures the server so /v1/nodes/name returns a 404
func (*IronicMock) Node ¶
func (m *IronicMock) Node(node nodes.Node) *IronicMock
Node configures the server with a valid response for /v1/nodes/{name,uuid}
func (*IronicMock) NodeError ¶
func (m *IronicMock) NodeError(name string, errorCode int) *IronicMock
NodeError configures the server to return the specified error code for /v1/nodes/name
func (*IronicMock) NodeUpdate ¶
func (m *IronicMock) NodeUpdate(node nodes.Node) *IronicMock
NodeUpdate configures the server with a valid response for PATCH for /v1/nodes/{name,uuid}
func (*IronicMock) NodeUpdateError ¶
func (m *IronicMock) NodeUpdateError(id string, errorCode int) *IronicMock
NodeUpdateError configures configures the server with an error response for [PATCH] /v1/nodes/{id}
func (*IronicMock) Nodes ¶
func (m *IronicMock) Nodes(allNodes []nodes.Node) *IronicMock
Nodes configure the server with a valid response for /v1/nodes
func (*IronicMock) NotReady ¶
func (m *IronicMock) NotReady(errorCode int) *IronicMock
NotReady configures the server with an error response for /v1
func (*IronicMock) Port ¶
func (m *IronicMock) Port(port ports.Port) *IronicMock
Port configures the server with a valid response for
[GET] /v1/nodes/<node uuid>/ports [GET] /v1/ports [GET] /v1/ports?address=<mac> [GET] /v1/ports?address=<mac>&fields=node_uuid
func (*IronicMock) Ready ¶
func (m *IronicMock) Ready() *IronicMock
Ready configures the server with a valid response for /v1
func (*IronicMock) WithDefaultResponses ¶
func (m *IronicMock) WithDefaultResponses() *IronicMock
WithDefaultResponses sets a valid answer for all the API calls
func (*IronicMock) WithDrivers ¶
func (m *IronicMock) WithDrivers() *IronicMock
WithDrivers configures the server so /v1/drivers returns a valid value
func (*IronicMock) WithNodeStatesPower ¶
func (m *IronicMock) WithNodeStatesPower(nodeUUID string, code int) *IronicMock
WithNodeStatesPower configures the server with a valid response for [GET] /v1/nodes/<node>/states/power
func (*IronicMock) WithNodeStatesPowerUpdate ¶
func (m *IronicMock) WithNodeStatesPowerUpdate(nodeUUID string, code int) *IronicMock
WithNodeStatesPowerUpdate configures the server with a valid response for [PUT] /v1/nodes/<node>/states/power
func (*IronicMock) WithNodeStatesProvision ¶
func (m *IronicMock) WithNodeStatesProvision(nodeUUID string) *IronicMock
WithNodeStatesProvision configures the server with a valid response for [GET] /v1/nodes/<node>/states/provision
func (*IronicMock) WithNodeStatesProvisionUpdate ¶
func (m *IronicMock) WithNodeStatesProvisionUpdate(nodeUUID string) *IronicMock
WithNodeStatesProvisionUpdate configures the server with a valid response for [PATCH] /v1/nodes/<node>/states/provision
func (*IronicMock) WithNodeValidate ¶
func (m *IronicMock) WithNodeValidate(nodeUUID string) *IronicMock
WithNodeValidate configures the server with a valid response for /v1/nodes/<node>/validate
type MockServer ¶
type MockServer struct { Requests string FullRequests []simpleRequest // contains filtered or unexported fields }
MockServer is a simple http testing server
func (*MockServer) AddDefaultResponse ¶
func (m *MockServer) AddDefaultResponse(patternWithVars string, httpMethod string, code int, payload string) *MockServer
AddDefaultResponse adds a default response for the specified pattern/method. It is possible to use variables in the pattern using curly braces, ie `/v1/nodes/{id}/power` Pattern variables can be reused in the payload, so that they will be substituted with the actual value when sending the response If httpMethod is empty, the response will be applied for any method
func (*MockServer) AddDefaultResponseJSON ¶
func (m *MockServer) AddDefaultResponseJSON(patternWithVars string, httpMethod string, code int, payload interface{}) *MockServer
AddDefaultResponseJSON adds a default response for the specified pattern
func (*MockServer) Endpoint ¶
func (m *MockServer) Endpoint() string
Endpoint returns the URL to the server
func (*MockServer) ErrorResponse ¶
func (m *MockServer) ErrorResponse(pattern string, errorCode int) *MockServer
ErrorResponse attaches a handler function that returns the given error code from requests to the URL pattern
func (*MockServer) GetLastRequestFor ¶
func (m *MockServer) GetLastRequestFor(pattern string, method string) (string, bool)
GetLastRequestFor returns the last request for the specified pattern/method. If method is empty, the response will be applied for any method
func (*MockServer) Handler ¶
func (m *MockServer) Handler(pattern string, handlerFunc http.HandlerFunc) *MockServer
Handler attaches a generic handler function to a request URL pattern
func (*MockServer) ResponseJSON ¶
func (m *MockServer) ResponseJSON(pattern string, payload interface{}) *MockServer
ResponseJSON marshals the JSON object as payload returned by the response handler
func (*MockServer) ResponseWithCode ¶
func (m *MockServer) ResponseWithCode(patternWithMethod string, payload string, code int) *MockServer
ResponseWithCode attaches a handler function that returns the given payload from requests to the URL pattern along with the specified code
func (*MockServer) SendJSONResponse ¶
func (m *MockServer) SendJSONResponse(payload interface{}, code int, w http.ResponseWriter, r *http.Request)
SendJSONResponse marshalls the payload to a JSON object and sends the response using the given writer
type NodeCreateCallback ¶
NodeCreateCallback type is the callback mock for CreateNodes