testutil

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: BlueOak-1.0.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertBoolPtr

func AssertBoolPtr(t *testing.T, got *bool, wantNil bool, wantVal bool, field string)

AssertBoolPtr checks a *bool field. When wantNil is true, it expects got to be nil. Otherwise it expects got to be non-nil with value wantVal.

func AssertStringPtr

func AssertStringPtr(t *testing.T, got *string, wantNil bool, wantVal string, field string)

AssertStringPtr checks a *string field. When wantNil is true, it expects got to be nil. Otherwise it expects got to be non-nil with value wantVal.

func CreateFile

func CreateFile(t *testing.T, dir, name string)

CreateFile creates a file at filepath.Join(dir, name) with dummy content. Parent directories are created as needed.

func NewTestClient

func NewTestClient(t *testing.T, server *httptest.Server) *api.RESTClient

NewTestClient creates an api.RESTClient that sends all requests to the given test server.

func WriteConfig

func WriteConfig(t *testing.T, dir, content string)

WriteConfig writes a .tailor.yml file in dir with the given content.

Types

type TestTransport

type TestTransport struct {
	Server *httptest.Server
}

TestTransport redirects all requests to the test server, preserving the original request path so the test handler can route by path.

func (*TestTransport) RoundTrip

func (t *TestTransport) 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