testserver

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Provides mongodb connection for tests only

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBufDialer

func GetBufDialer(listener *bufconn.Listener) func(context.Context, string) (net.Conn, error)

func InitGrpcTLSWithBuffConn

func InitGrpcTLSWithBuffConn(ctx context.Context, t *testing.T, allowPurge bool) *clientResult

func MongoDbConnect

func MongoDbConnect(ctx context.Context, timeoutSec int) (*mongo.Client, *dockertest.Pool, *dockertest.Resource)

Based on Dockertest

Example
package main

import (
	"context"
	"fmt"
	"time"

	"github.com/rsachdeva/illuminatingdeposits-grpc/testserver"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()

	_, pool, resource := testserver.MongoDbConnect(ctx, 10)
	err := pool.Purge(resource)
	fmt.Println("ExampleMongoDbConnect err is", err)
}
Output:

ExampleMongoDbConnect err is <nil>

Types

This section is empty.

Jump to

Keyboard shortcuts

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