package testing

import "cloud.google.com/go/logging/internal/testing"

Package testing provides support for testing the logging client.

Index

Constants

const (
	ValidProjectID = "PROJECT_ID"
	ValidOrgID     = "433637338589"

	SharedServiceAccount = "serviceAccount:cloud-logs@system.gserviceaccount.com"
)

The only IDs that WriteLogEntries will accept. Important for testing Ping.

Functions

func NewServer

func NewServer() (string, error)

NewServer creates a new in-memory fake server implementing the logging service. It returns the address of the server.

func PayloadEqual

func PayloadEqual(a, b interface{}) bool

PayloadEqual compares two payloads, assuming they are both proto.Messages or both strings.

func Retry

func Retry(t *testing.T, f func(r *testutil.R) error) bool

Retry is a wrapper around testutil.Retry that retries the test function on Unavailable errors, otherwise, Fatalfs.

func RetryAndExpectError

func RetryAndExpectError(t *testing.T, f func(r *testutil.R) error) bool

RetryAndExpectError retries the test function on Unavailable errors, otherwise passes if a different error was thrown. If no non-retryable error is returned, fails.

func RetryIteratorNext

func RetryIteratorNext[T any](t *testing.T, it Iterator[T]) (*T, bool)

RetryIteratorNext is a wrapper around testutil.Retry that retries the given iterator's Next function and returns the next object, retrying if a retryable error is found. If a non-retryable error is found, fail the test.

Types

type Iterator

type Iterator[T any] interface {
	Next() (*T, error)
}

Iterator is a wrapper interface type for iterators in the logadmin library that have a Next function that gets the next item/error, or returns nil/iterator.Done if the object has no next item.

Source Files

equal.go fake.go retry.go

Version
v1.13.0 (latest)
Published
Jan 2, 2025
Platform
linux/amd64
Imports
19 packages
Last checked
1 day ago

Tools for package owners.