Documentation ¶
Index ¶
- func HTTPRead(url string) (string, error)
- type HelloResponse
- type MockAPIServer
- func (m *MockAPIServer) Client() *cloudscale.Client
- func (m *MockAPIServer) Close()
- func (m *MockAPIServer) LastSent(v any)
- func (m *MockAPIServer) On(pattern string, status int, data any)
- func (m *MockAPIServer) Start()
- func (m *MockAPIServer) WithLoadBalancers(lbs []cloudscale.LoadBalancer)
- func (m *MockAPIServer) WithServers(servers []cloudscale.Server)
- type Node
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HelloResponse ¶
type HelloResponse struct { ServerAddress string ServerName string Date time.Time URI string RequestID string }
func HelloNginx ¶
func HelloNginx(addr string, port uint16) (*HelloResponse, error)
type MockAPIServer ¶
type MockAPIServer struct {
// contains filtered or unexported fields
}
MockAPIServer is a mock http server that builds on httptest.Server and http.ServeMux and provides methods to easily return mocked cloudscale API responses.
func NewMockAPIServer ¶
func NewMockAPIServer() *MockAPIServer
func (*MockAPIServer) Client ¶
func (m *MockAPIServer) Client() *cloudscale.Client
Client returns a cloudscale client pointing at the mock API server.
func (*MockAPIServer) Close ¶
func (m *MockAPIServer) Close()
Close stops/closes the server and resets it.
func (*MockAPIServer) LastSent ¶
func (m *MockAPIServer) LastSent(v any)
LastSent unmarshals the JSON last sent to the API server via POST/PUT/PATCH.
func (*MockAPIServer) On ¶
func (m *MockAPIServer) On(pattern string, status int, data any)
On matches the given pattern and returns a status and the given data. The data can be a string or anything that go can marshal into a JSON.
The servrer adds a default route that respods with an empty JSON object and a 404 status code.
Note, this method has no effect if the server is started, and all registered patterns need to be re-applied after the server is stopped using Close.
func (*MockAPIServer) Start ¶
func (m *MockAPIServer) Start()
Start runs the server in the background, until it is stopped/closed.
func (*MockAPIServer) WithLoadBalancers ¶
func (m *MockAPIServer) WithLoadBalancers(lbs []cloudscale.LoadBalancer)
WithLoadBalancers ensures that the /v1/loadbalancers endpoints respond with the given loadbalancer objects. In addition to /v1/loadbalancers, this also implements /v1/loadbalancers/<uuid> for any loadbalancer with a UUID.
func (*MockAPIServer) WithServers ¶
func (m *MockAPIServer) WithServers(servers []cloudscale.Server)
WithServers ensures that the /v1/servers endpoints respond with the given server objects. In addition to /v1/servers, this also implements /v1/servers/<uuid> for any server with a UUID.
type Node ¶
Node helps construct Kubernetes v1.Node objects for testing
func (*Node) WithProviderID ¶
type Service ¶
type Service struct {
Name string
}
Service helps construct Kubernetes v1.Service objects for testing