Skip to content
Snippets Groups Projects
Select Git revision
  • b4366c7db5f377bda5569e46f4085d3803c1a89b
  • master default protected
  • 0.1.1
  • 0.1.0
4 results

pkce.go

Blame
  • database_test.go 7.41 KiB
    //go:build !runOnTask
    
    package jobqueue
    
    import (
    	"context"
    	"fmt"
    	"github.com/docker/docker/api/types"
    	"github.com/docker/docker/api/types/container"
    	"github.com/docker/docker/client"
    	"github.com/docker/go-connections/nat"
    	"github.com/stretchr/testify/assert"
    	"gorm.io/driver/mysql"
    	"gorm.io/gorm"
    	"gorm.io/gorm/logger"
    	"log"
    	"net"
    	"os"
    	"runtime"
    	"strconv"
    	"sync"
    	"testing"
    	"time"
    )
    
    func startTestMySQLDockerImageAndContainer(t *testing.T, port string, ctx context.Context) error {
    	t.Helper()
    
    	cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
    	if err != nil {
    		return err
    	}
    
    	imageName := "mysql:8"
    
    	reader, err := cli.ImagePull(ctx, imageName, types.ImagePullOptions{})
    	if err != nil {
    		return err
    	}
    
    	// if debug image pull, comment out the following lines
    	//_, _ = io.Copy(os.Stdout, reader)
    	_ = reader
    
    	hostConfig := &container.HostConfig{
    		PortBindings: nat.PortMap{
    			"3306/tcp": []nat.PortBinding{
    				{
    					HostIP:   DOCKER_TEST_HOST_IP,
    					HostPort: port,
    				},
    			},
    			// if you want to test the web interface, uncomment the following lines
    			//"8025/tcp": []nat.PortBinding{
    			//	{
    			//		HostIP:   DOCKER_TEST_HOST_IP,
    			//		HostPort: "8025",
    			//	},
    			//},
    		},
    	}
    
    	resp, err := cli.ContainerCreate(ctx, &container.Config{
    		Image: imageName,
    		Env: []string{
    			"MYSQL_ROOT_PASSWORD=secret",
    			"MYSQL_USER=user",
    			"MYSQL_PASSWORD=secret",
    			"MYSQL_DATABASE=test",
    		},