### Initialize Monitor Client with Mock HTTP Client Source: https://pkg.go.dev/github.com/linode/linodego/test/unit SetUp initializes the Monitor client using the mock HTTP client. This is crucial for setting up tests for monitor-related functionalities. ```go func (c *MonitorClientBaseCase) SetUp(t *testing.T) ``` -------------------------------- ### Initialize Linode Client with Mock HTTP Client Source: https://pkg.go.dev/github.com/linode/linodego/test/unit SetUp initializes the Linode client using the mock HTTP client. This is essential for setting up test environments. ```go func (c *ClientBaseCase) SetUp(t *testing.T) ``` -------------------------------- ### Mock GET Request with ClientBaseCase Source: https://pkg.go.dev/github.com/linode/linodego/test/unit MockGet mocks a GET request to the client. Use this to simulate GET operations during testing. ```go func (c *ClientBaseCase) MockGet(path string, response interface{}) ``` -------------------------------- ### Create TestLogger Instance Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil Initializes and returns a new instance of TestLogger. ```go func CreateLogger() *TestLogger ``` -------------------------------- ### Create Mock HTTP Client Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil Use this function to create a mock HTTP client for testing purposes. It's generic to avoid cyclic dependencies when importing the linodego package. ```go func CreateMockClient[T any](t *testing.T, createFunc func(*http.Client) T) *T ``` -------------------------------- ### BuildClientsetFromConfig Function Signature Source: https://pkg.go.dev/github.com/linode/linodego/k8s Builds a Kubernetes Clientset from a given Kubeconfig. It accepts an optional transport.WrapperFunc for middleware. ```go func BuildClientsetFromConfig( lkeKubeconfig *linodego.LKEClusterKubeconfig, transportWrapper transport.WrapperFunc, ) (kubernetes.Interface, error) ``` -------------------------------- ### Mock POST Request with MonitorClientBaseCase Source: https://pkg.go.dev/github.com/linode/linodego/test/unit MockPost mocks a POST request for a given path with the provided response body. Use this to simulate POST operations on the Monitor client during testing. ```go func (c *MonitorClientBaseCase) MockPost(path string, response interface{}) ``` -------------------------------- ### Mock POST Request with ClientBaseCase Source: https://pkg.go.dev/github.com/linode/linodego/test/unit MockPost mocks a POST request for a given path with the provided response body. Use this to simulate POST operations during testing. ```go func (c *ClientBaseCase) MockPost(path string, response interface{}) ``` -------------------------------- ### BuildClientsetFromConfig Source: https://pkg.go.dev/github.com/linode/linodego/k8s Builds a Kubernetes Clientset from a given LKE cluster kubeconfig. It accepts an optional transport.WrapperFunc to apply middleware to API server requests. ```APIDOC ## func BuildClientsetFromConfig ### Description Builds a Clientset from a given Kubeconfig. Takes an optional transport.WrapperFunc to add request/response middleware to api-server requests. ### Signature ```go func BuildClientsetFromConfig( lkeKubeconfig *linodego.LKEClusterKubeconfig, transportWrapper transport.WrapperFunc, ) (kubernetes.Interface, error) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **kubernetes.Interface**: A Kubernetes client interface. - **error**: An error if the clientset cannot be built. #### Response Example None ``` -------------------------------- ### Mock PUT Request with ClientBaseCase Source: https://pkg.go.dev/github.com/linode/linodego/test/unit MockPut mocks a PUT request for a given path with the provided response body. Use this to simulate PUT operations during testing. ```go func (c *ClientBaseCase) MockPut(path string, response interface{}) ``` -------------------------------- ### Define MonitorClientBaseCase for Unit Tests Source: https://pkg.go.dev/github.com/linode/linodego/test/unit MonitorClientBaseCase provides a base structure for unit tests involving the Monitor client, including the Monitor client, a mock object, and the base URL. ```go type MonitorClientBaseCase struct { MonitorClient *linodego.MonitorClient Mock *mock.Mock BaseURL string // Base monitor-api URL } ``` -------------------------------- ### Mock Request with No Body Responder Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil Creates a mock responder for requests that are not expected to have a body. ```go func MockRequestBodyValidateNoBody(t *testing.T, response any) httpmock.Responder ``` -------------------------------- ### Define ClientBaseCase for Unit Tests Source: https://pkg.go.dev/github.com/linode/linodego/test/unit ClientBaseCase provides a base structure for unit tests, holding the Linode client, a mock object, and the base URL. ```go type ClientBaseCase struct { Client *linodego.Client Mock *mock.Mock BaseURL string // Base URL up to /v4 } ``` -------------------------------- ### TestLogger Warnf Method Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil Logs a warning message using the TestLogger. ```go func (l *TestLogger) Warnf(format string, v ...any) ``` -------------------------------- ### NewTRetry Function Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Constructor for TRetry. Initializes a new TRetry instance using a standard testing.T object. ```go func NewTRetry(t *testing.T) *TRetry ``` -------------------------------- ### Create New TestFixtures Instance Source: https://pkg.go.dev/github.com/linode/linodego/test/unit NewTestFixtures creates and returns a new instance of TestFixtures. Use this to initialize the fixture manager for your tests. ```go func NewTestFixtures() *TestFixtures ``` -------------------------------- ### TRetry TempDir Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Returns a temporary directory that will be removed when the test finishes. Useful for creating temporary files. ```go func (t *TRetry) TempDir() string ``` -------------------------------- ### TestLogger Struct Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil A concrete implementation of the Logger interface that uses Go's standard log.Logger. ```go type TestLogger struct { L *log.Logger } ``` -------------------------------- ### Mock DELETE Request with ClientBaseCase Source: https://pkg.go.dev/github.com/linode/linodego/test/unit MockDelete mocks a DELETE request for a given path with the provided response body. Use this to simulate DELETE operations during testing. ```go func (c *ClientBaseCase) MockDelete(path string, response interface{}) ``` -------------------------------- ### NewTRetry Function Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Creates a new instance of TRetry, initializing it with a testing.T instance. ```APIDOC ## func NewTRetry ```go func NewTRetry(t *testing.T) *TRetry ``` Creates a new TRetry instance. ``` -------------------------------- ### Mock Request URL Matcher Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil Generates a regular expression to match a specific URL path for request mocking. ```go func MockRequestURL(path string) *regexp.Regexp ``` -------------------------------- ### Mock Request Body Validation Responder Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil Creates a mock responder that validates the request body against an expected value. ```go func MockRequestBodyValidate(t *testing.T, expected any, response any) httpmock.Responder ``` -------------------------------- ### TRetry Formatted Log Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Logs a formatted message during test execution. Use for detailed, non-error related output. ```go func (t *TRetry) Logf(format string, args ...any) ``` -------------------------------- ### TRetry Setenv Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Sets an environment variable for the duration of the test. This is useful for configuring external dependencies. ```go func (t *TRetry) Setenv(key, value string) ``` -------------------------------- ### Logger Interface Definition Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil Defines a standard interface for logging within tests, supporting Errorf, Warnf, and Debugf methods. ```go type Logger interface { Errorf(format string, v ...any) Warnf(format string, v ...any) Debugf(format string, v ...any) } ``` -------------------------------- ### TRetry FailNow Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Marks the current test as failed and stops its execution immediately. Use this for critical failures. ```go func (t *TRetry) FailNow() ``` -------------------------------- ### TestLogger Debugf Method Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil Logs a debug message using the TestLogger. ```go func (l *TestLogger) Debugf(format string, v ...any) ``` -------------------------------- ### TestLogger Errorf Method Source: https://pkg.go.dev/github.com/linode/linodego/internal/testutil Logs an error message using the TestLogger. ```go func (l *TestLogger) Errorf(format string, v ...any) ``` -------------------------------- ### TRetry Cleanup Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Schedules a function to be run when the TRetry is closed. Useful for resource cleanup in tests. ```go func (t *TRetry) Cleanup(f func()) ``` -------------------------------- ### Define TestFixtures Structure Source: https://pkg.go.dev/github.com/linode/linodego/test/unit TestFixtures manages the loading and retrieval of test fixtures, which are pre-defined data used in tests. ```go type TestFixtures struct { // contains filtered or unexported fields } ``` -------------------------------- ### TRetry Methods Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Provides a comprehensive set of methods for managing test execution, logging, and retry logic. ```APIDOC ## TRetry Methods ### Cleanup ```go func (t *TRetry) Cleanup(f func()) ``` Registers a function to be run when the test is cleaned up. ### Close ```go func (t *TRetry) Close() ``` Closes the TRetry instance, releasing any resources. ### Error ```go func (t *TRetry) Error(args ...any) ``` Logs an error message without stopping the test. ### Errorf ```go func (t *TRetry) Errorf(format string, args ...any) ``` Logs a formatted error message without stopping the test. ### Fail ```go func (t *TRetry) Fail() ``` Marks the test as failed, but continues execution. ### FailNow ```go func (t *TRetry) FailNow() ``` Marks the test as failed and stops execution immediately. ### Failed ```go func (t *TRetry) Failed() bool ``` Returns true if the test has been marked as failed. ### Fatal ```go func (t *TRetry) Fatal(args ...any) ``` Logs a fatal error message and stops the test execution. ### Fatalf ```go func (t *TRetry) Fatalf(format string, args ...any) ``` Logs a formatted fatal error message and stops the test execution. ### Helper ```go func (t *TRetry) Helper() ``` Marks the current function as a test helper function. ### Log ```go func (t *TRetry) Log(args ...any) ``` Logs a message to the test output. ### Logf ```go func (t *TRetry) Logf(format string, args ...any) ``` Logs a formatted message to the test output. ### Name ```go func (t *TRetry) Name() string ``` Returns the name of the test. ### Parallel ```go func (t *TRetry) Parallel() ``` Marks the test to be run in parallel. ### Setenv ```go func (t *TRetry) Setenv(key, value string) ``` Sets an environment variable for the test. ### Skip ```go func (t *TRetry) Skip(args ...any) ``` Logs a message and skips the test. ### SkipNow ```go func (t *TRetry) SkipNow() ``` Skips the test immediately. ### Skipf ```go func (t *TRetry) Skipf(format string, args ...any) ``` Logs a formatted message and skips the test. ### Skipped ```go func (t *TRetry) Skipped() bool ``` Returns true if the test has been skipped. ### TempDir ```go func (t *TRetry) TempDir() string ``` Returns a temporary directory for the test to use. ``` -------------------------------- ### TRetry SkipNow Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Skips the current test immediately. Similar to testing.T.SkipNow. ```go func (t *TRetry) SkipNow() ``` -------------------------------- ### TRetry Fail Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Marks the current test as failed, but continues execution. Use this to indicate a test condition was not met. ```go func (t *TRetry) Fail() ``` -------------------------------- ### Tear Down Monitor Test Environment Source: https://pkg.go.dev/github.com/linode/linodego/test/unit TearDown performs cleanup operations after a monitor-related test. Ensure this is called to reset the test environment. ```go func (c *MonitorClientBaseCase) TearDown(t *testing.T) ``` -------------------------------- ### Define MockResponse Structure Source: https://pkg.go.dev/github.com/linode/linodego/test/unit MockResponse defines the structure for mock HTTP responses, including status code and body. ```go type MockResponse struct { StatusCode int Body interface{} } ``` -------------------------------- ### Tear Down Test Environment Source: https://pkg.go.dev/github.com/linode/linodego/test/unit TearDown performs cleanup operations after a test. Ensure this is called to reset the test environment. ```go func (c *ClientBaseCase) TearDown(t *testing.T) ``` -------------------------------- ### TRetry Parallel Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Marks the current test as capable of running in parallel with other tests. Requires `t.Parallel()` to be called. ```go func (t *TRetry) Parallel() ``` -------------------------------- ### TRetry Skipf Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Skips the current test with a formatted message. Use for providing reasons why a test was skipped. ```go func (t *TRetry) Skipf(format string, args ...any) ``` -------------------------------- ### TRetry Helper Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Marks the current function as a test helper function. This affects error reporting and test progress. ```go func (t *TRetry) Helper() ``` -------------------------------- ### TRetry Formatted Error Logging Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Logs a formatted non-fatal error message. Use this for detailed error reporting within tests. ```go func (t *TRetry) Errorf(format string, args ...any) ``` -------------------------------- ### WaitForLKEClusterReady Source: https://pkg.go.dev/github.com/linode/linodego/k8s/pkg/condition WaitForLKEClusterReady polls with a given timeout for the LKE Cluster's api-server to be healthy and for the cluster to have at least one node with the NodeReady condition true. ```APIDOC ## WaitForLKEClusterReady ### Description Waits for the LKE Cluster's API server to be healthy and for at least one node to be ready. ### Function Signature ```go func WaitForLKEClusterReady(ctx context.Context, client linodego.Client, clusterID int, options linodego.LKEClusterPollOptions) error ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (error) - **error**: nil if the cluster becomes ready within the timeout, otherwise an error indicating the reason for failure. ### Response Example None ``` -------------------------------- ### Wait for LKE Cluster Ready Source: https://pkg.go.dev/github.com/linode/linodego/k8s/pkg/condition WaitForLKEClusterReady polls until the LKE Cluster's API server is healthy and at least one node is ready. It includes a timeout mechanism to prevent indefinite waiting. ```go func WaitForLKEClusterReady(ctx context.Context, client linodego.Client, clusterID int, options linodego.LKEClusterPollOptions) error ``` -------------------------------- ### TRetry Name Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Returns the name of the current test. This is useful for identifying tests in logs or reports. ```go func (t *TRetry) Name() string ``` -------------------------------- ### TRetry Formatted Fatal Logging Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Logs a formatted fatal error message and stops the current test's execution. Use for critical, detailed error reporting. ```go func (t *TRetry) Fatalf(format string, args ...any) ``` -------------------------------- ### TRetry Log Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Logs a message during test execution. This message is not considered an error and does not stop the test. ```go func (t *TRetry) Log(args ...any) ``` -------------------------------- ### Retrieve Test Fixture Data Source: https://pkg.go.dev/github.com/linode/linodego/test/unit GetFixture retrieves the fixture data associated with the given name. This is useful for loading specific test data. ```go func (tf *TestFixtures) GetFixture(name string) (interface{}, error) ``` -------------------------------- ### TRetry Skip Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Skips the current test. The test will be reported as skipped and execution will stop. ```go func (t *TRetry) Skip(args ...any) ``` -------------------------------- ### TRetry Error Logging Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Logs a non-fatal error message. Similar to testing.T.Error, but integrated with TRetry's error handling. ```go func (t *TRetry) Error(args ...any) ``` -------------------------------- ### TRetry Struct Definition Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Defines the TRetry struct, which implements testing.T with added retry logic. It includes channels for error and success signaling. ```go type TRetry struct { ErrorChannel chan error SuccessChannel chan bool // contains filtered or unexported fields } ``` -------------------------------- ### TRetry Close Method Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Closes the TRetry instance, releasing any associated resources. This should be called to ensure proper cleanup. ```go func (t *TRetry) Close() ``` -------------------------------- ### Check if Cluster Has Ready Node Source: https://pkg.go.dev/github.com/linode/linodego/k8s/pkg/condition Use ClusterHasReadyNode to poll for at least one node with the NodeReady condition set to True. This is useful for ensuring a cluster is operational before proceeding with further actions. ```go func ClusterHasReadyNode(ctx context.Context, options linodego.ClusterConditionOptions) (bool, error) ``` -------------------------------- ### TRetry Fatal Logging Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Logs a fatal error message and stops the current test's execution. Similar to testing.T.Fatal. ```go func (t *TRetry) Fatal(args ...any) ``` -------------------------------- ### UnmarshalJSON Method Signature Source: https://pkg.go.dev/github.com/linode/linodego/internal/parseabletime Provides the signature for the UnmarshalJSON method on ParseableTime. This method is part of the json.Unmarshaler interface, enabling custom JSON parsing for this type. ```go func (p *ParseableTime) UnmarshalJSON(b []byte) error ``` -------------------------------- ### TRetry Failed Status Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Returns true if the test has already been marked as failed. Useful for checking test status. ```go func (t *TRetry) Failed() bool ``` -------------------------------- ### UnmarshalTimeRemaining Function Signature Source: https://pkg.go.dev/github.com/linode/linodego/internal/duration This is the function signature for UnmarshalTimeRemaining. It takes a json.RawMessage and returns a pointer to an integer. ```go func UnmarshalTimeRemaining(m json.RawMessage) *int ``` -------------------------------- ### TRetry Skipped Status Source: https://pkg.go.dev/github.com/linode/linodego/test/integration Returns true if the test has been skipped. Useful for checking the test's current state. ```go func (t *TRetry) Skipped() bool ``` -------------------------------- ### TRetry Type Source: https://pkg.go.dev/github.com/linode/linodego/test/integration The TRetry type implements testing.T with additional retry logic, providing channels for error and success reporting. ```APIDOC ## Type TRetry ```go type TRetry struct { ErrorChannel chan error SuccessChannel chan bool // contains filtered or unexported fields } ``` TRetry implements testing.T with additional retry logic. ``` -------------------------------- ### ClusterHasReadyNode Source: https://pkg.go.dev/github.com/linode/linodego/k8s/pkg/condition ClusterHasReadyNode is a ClusterConditionFunc which polls for at least one node to have the condition NodeReady=True. ```APIDOC ## ClusterHasReadyNode ### Description Checks if at least one node in the cluster has the NodeReady condition set to True. ### Function Signature ```go func ClusterHasReadyNode(ctx context.Context, options linodego.ClusterConditionOptions) (bool, error) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (bool, error) - **bool**: True if a ready node is found, false otherwise. - **error**: An error if the operation fails. ### Response Example None ``` -------------------------------- ### UnmarshalTimeRemaining Function Source: https://pkg.go.dev/github.com/linode/linodego/internal/duration Unmarshals a JSON raw message into a pointer to an integer representing time remaining. ```APIDOC ## func UnmarshalTimeRemaining ### Description Unmarshals a JSON raw message into a pointer to an integer representing time remaining. ### Signature ```go func UnmarshalTimeRemaining(m json.RawMessage) *int ``` ### Parameters * **m** (json.RawMessage) - The raw JSON message to unmarshal. ### Returns * **(*int)** - A pointer to an integer representing the time remaining, or nil if unmarshalling fails. ``` -------------------------------- ### ParseableTime.UnmarshalJSON Source: https://pkg.go.dev/github.com/linode/linodego/internal/parseabletime UnmarshalJSON parses a JSON byte slice into a ParseableTime type. This is useful for handling time values in JSON payloads. ```APIDOC ## func (*ParseableTime) UnmarshalJSON ### Description Parses a JSON byte slice into a ParseableTime type. ### Signature ```go func (p *ParseableTime) UnmarshalJSON(b []byte) error ``` ### Parameters * **b** ([]byte) - The JSON byte slice to unmarshal. ``` -------------------------------- ### ParseableTime Type Definition Source: https://pkg.go.dev/github.com/linode/linodego/internal/parseabletime Defines ParseableTime as an alias for time.Time. This type is likely used for custom JSON unmarshalling logic. ```go type ParseableTime time.Time ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.