Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupRegistry ¶ added in v0.6.1
func SetupRegistry(ctx context.Context, t *testing.T, projectID string, seeds []seeder.RegistryResource) (*gapic.RegistryClient, *gapic.AdminClient)
SetupRegistry connects to a registry instance using the default config, deletes the project if it exists, seeds the registry for testing, and returns the connections used. It also registers cleanup handlers on the test to close the connections and delete the project.
func TestMain ¶
TestMain can delegate here in packages that wish to use TestMain() for tests relying on a RegistryServer. Note: As TestMain() is run once per TestXXX() function, this will create a new database for the function, not per t.Run() within it. See NewIfNoAddress() for details. Example:
func TestMain(m *testing.M) { grpctest.TestMain(m, registry.Config{}) }
Types ¶
type Server ¶
type Server struct { Server *grpc.Server Listener net.Listener Registry *registry.RegistryServer TmpDir string }
Server wraps a gRPC Server for a RegistryServer
func NewIfNoAddress ¶
NewIfNoAddress will create a RegistryServer served by a basic grpc.Server if env var APG_REGISTRY_ADDRESS is not set, see NewServer() for details. If APG_REGISTRY_ADDRESS is set, returns nil as client will connect to that remote address. Example:
func TestXXX(t *testing.T) { l, err := grpctest.NewIfNoAddress(registry.Config{}) if err != nil { t.Fatal(err) } defer l.Close() ... run test here ... }
func NewServer ¶
NewServer creates a RegistryServer served by a basic grpc.Server. If rc.Database and rc.DBConfig are blank, a RegistryServer using sqlite3 on a tmpDir is automatically created. registry.address and registry.insecure configuration values are set to cause the in-process client to connect to the created grpc service. Call Close() when done to close server and clean up tmpDir as needed. Example:
func TestXXX(t *testing.T) { l, err := grpctest.NewServer(registry.Config{}) if err != nil { t.Fatal(err) } defer l.Close() ... run test here ... }