Merged in jb/openapi (pull request #22)
add openapi infra * add openapi infra Includes generated stubs and all deps * generatetolocation * basesetupoffunctionsandclient * round1controllertests * passintegrationtests * cleanupfromfullsuite * storedjson * fixjsonyaml * fixtests Approved-by: Michael McGuinness
This commit is contained in:
committed by
Michael McGuinness
parent
5ca36b0502
commit
174644b63c
+5
-22
@@ -7,8 +7,6 @@ import (
|
||||
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
type APIContainerConfig struct {
|
||||
@@ -17,7 +15,7 @@ type APIContainerConfig struct {
|
||||
Network *testcontainers.DockerNetwork
|
||||
}
|
||||
|
||||
func CreateAPIContainer(t *testing.T, ctx context.Context, config *APIContainerConfig) (*grpc.ClientConn, func()) {
|
||||
func CreateAPIContainer(t *testing.T, ctx context.Context, config *APIContainerConfig) (string, func()) {
|
||||
port, err := nat.NewPort("tcp", "8080")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create port: %v", err)
|
||||
@@ -40,38 +38,23 @@ func CreateAPIContainer(t *testing.T, ctx context.Context, config *APIContainerC
|
||||
t.Fatalf("Failed to extract port: %v", err)
|
||||
}
|
||||
|
||||
conn, err := grpc.NewClient(
|
||||
fmt.Sprintf("%s:%s", host, mappedPort.Port()),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to connect to gRPC server: %v", err)
|
||||
}
|
||||
|
||||
return conn, func() {
|
||||
err = conn.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
cleanup()
|
||||
}
|
||||
return fmt.Sprintf("http://%s:%s", host, mappedPort.Port()), cleanup
|
||||
}
|
||||
|
||||
func CreateAPIWithDependencies(t *testing.T, ctx context.Context, serviceName string) (*grpc.ClientConn, func()) {
|
||||
func CreateAPIWithDependencies(t *testing.T, ctx context.Context, serviceName string) (string, func()) {
|
||||
network, ncleanup := CreateNetwork(t, ctx)
|
||||
|
||||
dbconfig, dbcleanup := CreateDB(t, ctx, &CreateDatabaseConfig{
|
||||
Network: network,
|
||||
})
|
||||
|
||||
conn, ccleanup := CreateAPIContainer(t, ctx, &APIContainerConfig{
|
||||
address, ccleanup := CreateAPIContainer(t, ctx, &APIContainerConfig{
|
||||
ServiceName: serviceName,
|
||||
DB: dbconfig.External,
|
||||
Network: network,
|
||||
})
|
||||
|
||||
return conn, func() {
|
||||
return address, func() {
|
||||
ncleanup()
|
||||
dbcleanup()
|
||||
ccleanup()
|
||||
|
||||
Reference in New Issue
Block a user