Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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. APG_REGISTRY_ADDRESS and APG_REGISTRY_INSECURE env vars are set for the 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 ... }