Documentation ¶
Index ¶
- func AssertReadDoesNotReturnBefore(t testing.TB, ch <-chan struct{}, timeout time.Duration)
- func AssertReadReturnsBefore(t testing.TB, ch <-chan struct{}, timeout time.Duration)
- func AssertReadReturnsBetween(t testing.TB, ch <-chan struct{}, x, y time.Duration)
- func CopyFile(t testing.TB, src, dst string)
- func ExpandPath(file string) string
- func LoadChain(t *testing.T, file string) []*x509.Certificate
- func LoadSigner(t *testing.T, file string) crypto.Signer
- func LoadTRC(t *testing.T, file string) cppki.SignedTRC
- func MustExtractIA(t *testing.T, cert *x509.Certificate) addr.IA
- func MustMarshalJSONToFile(t testing.TB, v interface{}, baseName string)
- func MustParseCIDR(t *testing.T, s string) *net.IPNet
- func MustParseCIDRs(t *testing.T, entries ...string) []*net.IPNet
- func MustParseHexString(s string) []byte
- func MustParseIP(t *testing.T, addr string) net.IP
- func MustParseIPPrefixes(t *testing.T, prefixes ...string) []netip.Prefix
- func MustParseTime(t *testing.T, s string) time.Time
- func MustParseUDPAddr(t *testing.T, s string) *net.UDPAddr
- func MustParseUDPAddrs(t *testing.T, entries ...string) []*net.UDPAddr
- func MustReadFromFile(t testing.TB, baseName string) []byte
- func MustTempDir(dir, prefix string) (string, func())
- func MustTempFileName(dir, prefix string) string
- func MustWriteToFile(t testing.TB, b []byte, baseName string)
- func SanitizedName(t testing.TB) string
- func TempFileName(dir, prefix string) (string, error)
- func UpdateGoldenFiles() *bool
- func UpdateNonDeterminsticGoldenFiles() *bool
- func WithCredentials(client, server credentials.TransportCredentials) func(*grpcServiceOptions)
- func WithInsecureCredentials() func(*grpcServiceOptions)
- type GRPCService
- type GRPCServiceOption
- type PanickingReporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertReadDoesNotReturnBefore ¶
AssertReadDoesNotReturnBefore will call t.Fatalf if the first read from the channel happens before timeout.
func AssertReadReturnsBefore ¶
AssertReadReturnsBefore will call t.Fatalf if the first read from the channel doesn't happen before timeout.
func AssertReadReturnsBetween ¶
AssertReadReturnsBetween will call t.Fatalf if the first read from the channel doesn't happen between x and y.
func LoadChain ¶
func LoadChain(t *testing.T, file string) []*x509.Certificate
LoadChain loads a certificate chain from a file. The file must be PEM encoded.
func LoadSigner ¶
LoadSigner loads a private key from a file. The file must be PEM encoded.
func MustExtractIA ¶
MustExtractIA extracts the IA from the cert's subject and verifies it is non-nil. It is the callers responsibility to make sure that this is a cert that always contains an IA.
func MustMarshalJSONToFile ¶
MustMarshalJSONToFile marshals v and writes the result to file testdata/baseName. If the file exists, it is truncated; if it doesn't exist, it is created. On errors, t.Fatal() is called.
func MustParseCIDR ¶
MustParseCIDR parses s and returns the corresponding net.IPNet object. It fails the test if s is not a valid CIDR string.
func MustParseCIDRs ¶
MustParseCIDRs parses the CIDR entries and returns a list containing the parsed net.IPNet objects.
func MustParseHexString ¶
MustParseHexString parses s and returns the corresponding byte slice. It panics if the decoding fails.
func MustParseIP ¶
MustParseIP parses an IP address and returns the parsed net.IP object.
func MustParseIPPrefixes ¶
MustParseIPPrefixes parses the CIDR entries and returns a list containing the parsed netip.Prefix objects.
func MustParseTime ¶ added in v0.11.0
MustParseTime parses s and returns the corresponding time.Time object. It fails the test if s is not a valid time string.
func MustParseUDPAddr ¶
MustParseUDPAddr parses s and returns the corresponding net.UDPAddr object. It fails the test if s is not a valid UDP address string.
func MustParseUDPAddrs ¶
MustParseUDPAddrs parses the UPD address entries and returns a list containing the parsed net.UDPAddr objects.
func MustReadFromFile ¶
MustReadFromFile reads testdata/baseName and returns the raw content. On errors, t.Fatal() is called.
func MustTempDir ¶
MustTempDir creates a new temporary directory under dir with the specified prefix. If the function encounters an error it panics. The second return value is a clean-up function that can be called to recursively delete the entire directory.
func MustTempFileName ¶
MustTempFileName is a wrapper around TempFileName. The function panics if an error occurs. It is intended for tests where error handling is not necessary, and for chaining functions.
func MustWriteToFile ¶
MustWriteToFile writes b to file testdata/baseName. If the file exists, it is truncated; if it doesn't exist, it is created. On errors, t.Fatal() is called.
func SanitizedName ¶
SanitizedName sanitizes the test name such that it can be used as a file name.
func TempFileName ¶
TempFileName creates a temporary file in dir with the specified prefix, and then closes and deletes the file and returns its name. It is useful for testing packages that care about a unique path without being able to overwrite it (e.g., UNIX domain socket addresses or databases).
func UpdateGoldenFiles ¶
func UpdateGoldenFiles() *bool
Update registers the '-update' flag for the test.
This flag should be checked by golden file tests to see whether the golden files should be updated or not. The golden files should be deterministic. Use UpdateNonDeterminsticGoldenFiles instead, if they are not deterministic.
To update all golden files, run the following command:
go test ./... -update
To update a specific package, run the following command:
go test ./path/to/package -update
The flag should be registered as a package global variable:
var update = xtest.UpdateGoldenFiles()
func UpdateNonDeterminsticGoldenFiles ¶
func UpdateNonDeterminsticGoldenFiles() *bool
UpdateNonDeterminsticGoldenFiles registers the '-update-non-deterministic' flag for the test.
This flag should be checked by golden file tests to see whether the non-deterministic golden files should be updated or not.
To update all golden files, run the following command:
go test ./... -update-non-deterministic
To update a specific package, run the following command:
go test ./path/to/package -update-non-deterministic
The flag should be registered as a package global variable:
var updateNonDeterministic = xtest.UpdateNonDeterminsticGoldenFiles()
func WithCredentials ¶ added in v0.9.0
func WithCredentials(client, server credentials.TransportCredentials) func(*grpcServiceOptions)
func WithInsecureCredentials ¶ added in v0.9.0
func WithInsecureCredentials() func(*grpcServiceOptions)
Types ¶
type GRPCService ¶
type GRPCService struct {
// contains filtered or unexported fields
}
func NewGRPCService ¶
func NewGRPCService(options ...GRPCServiceOption) *GRPCService
func (*GRPCService) Dial ¶
func (s *GRPCService) Dial(ctx context.Context, addr net.Addr) (*grpc.ClientConn, error)
func (*GRPCService) Server ¶
func (s *GRPCService) Server() *grpc.Server
func (*GRPCService) Start ¶
func (s *GRPCService) Start(t *testing.T)
type GRPCServiceOption ¶ added in v0.9.0
type GRPCServiceOption func(*grpcServiceOptions)
type PanickingReporter ¶
PanickingReporter is a wrapper around the *testing.T implementation of gomock.TestReporter which panics and logs on FatalF instead of calling runtime.Goexit(). This avoids deadlocks when a child goroutine fails a mocking constraint when using gomock.
For more information, see https://github.com/golang/mock/issues/139.
func (*PanickingReporter) Fatalf ¶
func (reporter *PanickingReporter) Fatalf(format string, args ...interface{})
Directories ¶
Path | Synopsis |
---|---|
Code generated by graphupdater tool, DO NOT EDIT.
|
Code generated by graphupdater tool, DO NOT EDIT. |