github.com/kubecost/golang-migrate-duckdb/v4@v4.17.0-duckdb.1/dktesting/dktesting.go (about)

     1  package dktesting
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  import (
     8  	"github.com/dhui/dktest"
     9  )
    10  
    11  // ContainerSpec holds Docker testing setup specifications
    12  type ContainerSpec struct {
    13  	ImageName string
    14  	Options   dktest.Options
    15  }
    16  
    17  // ParallelTest runs Docker tests in parallel
    18  func ParallelTest(t *testing.T, specs []ContainerSpec,
    19  	testFunc func(*testing.T, dktest.ContainerInfo)) {
    20  
    21  	for i, spec := range specs {
    22  		spec := spec // capture range variable, see https://goo.gl/60w3p2
    23  
    24  		// Only test against one version in short mode
    25  		// TODO: order is random, maybe always pick first version instead?
    26  		if i > 0 && testing.Short() {
    27  			t.Logf("Skipping %v in short mode", spec.ImageName)
    28  		} else {
    29  			t.Run(spec.ImageName, func(t *testing.T) {
    30  				t.Parallel()
    31  				dktest.Run(t, spec.ImageName, spec.Options, testFunc)
    32  			})
    33  		}
    34  	}
    35  }