{"modulePath":"github.com/cloudzero/cloudzero-agent","version":"v1.2.7","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\nPackage utils provides utilities supporting the smoke tests.\n\nPackage utils contains higher-level (e.g., integration) tests.\n\n## Functions\n\n```go\nfunc ContainerExternalHost(ctx context.Context, container testcontainers.Container, port string) (*url.URL, error)\n```\nContainerExternalHost gets the external host of for a specific container based on what port testcontainers forwarded to on the host machine.\n\nThis is only needed for external communications between application and the container. This is NOT needed for container to container interactions on the same network\n\n```go\nfunc ContainerHasLogMessage(\n\tctx context.Context,\n\tinput *ContainerHasLogMessageInput,\n) (bool, error)\n```\nContainerHasLogMessage checks the container log buffer for a specific string message\n\n```go\nfunc ContainerWaitForLog(ctx context.Context, input *WaitForLogInput) error\n```\nContainerWaitForLog polls the logs of the container to see if a \\`log\\` message exists. If the timeout is exceeded, an error returns.\n\n```go\nfunc WaitForCondition(\n\tctx context.Context,\n\ttimeout time.Duration,\n\tpoll time.Duration,\n\tcondition func() (bool, error),\n) error\n```\nWaitForCondition waits for a specific condition to return true.\n\n## Types\n\n```go\ntype ContainerHasLogMessageInput struct {\n\tContainer  *testcontainers.Container\n\tLog        string\n\tAllowError bool\n\tN          int\n}\n```\n\n```go\ntype LogCapture struct {\n\tLines []string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewLogCapture(logger *logrus.Logger) *LogCapture\n```\nNewLogCapture sets up plain text logging to be captured for testing purposes\n\n```go\nfunc NewLogCaptureWithCurrentFormatter(logger *logrus.Logger) *LogCapture\n```\nNewLogCaptureWithCurrentFormatter sets up capture with current formatter\n\n```go\nfunc (l *LogCapture) Clear()\n```\nClear clears captured lines\n\n```go\nfunc (l *LogCapture) Extract(index int, key string) string\n```\nExtract looks for a key=value pair for line at given index, returning the value or empty if not found. This is possible because we log using plain text logging.\n\n```go\nfunc (l *LogCapture) Len() int\n```\nLen returns number of log lines captured\n\n```go\nfunc (l *LogCapture) Write(p []byte) (n int, err error)\n```\nWrite echos line to console and captures same line\n\n```go\ntype MockRoundTripper struct {\n\tResponses map[string][]*http.Response\n\tErrors    map[string][]error\n}\n```\n\n```go\nfunc NewHTTPMock() *MockRoundTripper\n```\n\n```go\nfunc (m *MockRoundTripper) Expect(method string, body string, status int, err error)\n```\n\n```go\nfunc (m *MockRoundTripper) HTTPClient() *http.Client\n```\n\n```go\nfunc (m *MockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)\n```\n\n```go\ntype WaitForLogInput struct {\n\tContainer  *testcontainers.Container\n\tLog        string\n\tTimeout    time.Duration\n\tPoll       time.Duration\n\tAllowError bool // if errors should not fail the search\n\tN          int\n}\n```\n\n","path":"github.com/cloudzero/cloudzero-agent/tests/utils","name":"utils","synopsis":"Package utils provides utilities supporting the smoke tests.","isRedistributable":true}
