testutil

package
v0.0.0-...-b4fc3f1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyType

func AnyType() schema.Type

func BindFailure

func BindFailure(t testing.TB, n ipld.Node) fdm.FailureModel

BindFailure binds the IPLD node to a FailureModel if possible. This works around IPLD requiring data to match the schema exactly

func GetFreePort

func GetFreePort(t *testing.T) int

GetFreePort asks the kernel for a free open port that is ready to use.

func Must

func Must[T any](val T, err error) func(*testing.T) T

Must takes return values from a function and returns the non-error one. If the error value is non-nil then it fails the test

func Must2

func Must2[T, U any](val1 T, val2 U, err error) func(*testing.T) (T, U)

Must2 takes return values from a 3 return function and returns the non-error ones. If the error value is non-nil then it fails the test.

func RandomBytes

func RandomBytes(t *testing.T, size int) (multihash.Multihash, []byte)

func RandomCAR

func RandomCAR(t *testing.T, size int) (ipld.Link, multihash.Multihash, multihash.Multihash, []byte)

RandomCAR creates a CAR with a single block of random bytes of the specified size. It returns the link of the root block, the hash of the root block, the hash of the CAR itself and the bytes of the CAR.

func RandomCID

func RandomCID(t *testing.T) ipld.Link

func RandomLocalURL

func RandomLocalURL(t *testing.T) url.URL

RandomLocalURL finds a free port and will not generate another URL with the same port until test cleanup, even if no service is bound to it.

func RandomPrincipal

func RandomPrincipal(t *testing.T) ucan.Principal

func RandomSigner

func RandomSigner(t *testing.T) principal.Signer

Types

This section is empty.

Jump to

Keyboard shortcuts

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