test

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

SPDX-FileCopyrightText: Copyright (c) 2016-2024, CloudZero, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

SPDX-FileCopyrightText: Copyright (c) 2016-2024, CloudZero, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogCapture

type LogCapture struct {
	Lines []string
	// contains filtered or unexported fields
}

func NewLogCapture

func NewLogCapture(logger *logrus.Logger) *LogCapture

NewLogCapture sets up plain text logging to be captured for testing purposes

func NewLogCaptureWithCurrentFormatter

func NewLogCaptureWithCurrentFormatter(logger *logrus.Logger) *LogCapture

NewLogCaptureWithCurrentFormatter sets up capture with current formatter

func (*LogCapture) Clear

func (l *LogCapture) Clear()

Clear clears captured lines

func (*LogCapture) Extract

func (l *LogCapture) Extract(index int, key string) string

Extract 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.

func (*LogCapture) Len

func (l *LogCapture) Len() int

Len returns number of log lines captured

func (*LogCapture) Write

func (l *LogCapture) Write(p []byte) (n int, err error)

Write echos line to console and captures same line

type MockRoundTripper

type MockRoundTripper struct {
	Responses map[string][]*http.Response
	Errors    map[string][]error
}

func NewHTTPMock

func NewHTTPMock() *MockRoundTripper

func (*MockRoundTripper) Expect

func (m *MockRoundTripper) Expect(method string, body string, status int, err error)

func (*MockRoundTripper) HTTPClient

func (m *MockRoundTripper) HTTPClient() *http.Client

func (*MockRoundTripper) RoundTrip

func (m *MockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL