github.com/weaviate/weaviate@v1.24.6/test/modules/ref2vec-centroid/setup_test.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package test
    13  
    14  import (
    15  	"context"
    16  	"os"
    17  	"testing"
    18  
    19  	"github.com/pkg/errors"
    20  	"github.com/weaviate/weaviate/test/docker"
    21  )
    22  
    23  const weaviateEndpoint = "WEAVIATE_ENDPOINT"
    24  
    25  func TestMain(m *testing.M) {
    26  	ctx := context.Background()
    27  	compose, err := docker.New().
    28  		WithWeaviate().WithRef2VecCentroid().
    29  		Start(ctx)
    30  	if err != nil {
    31  		panic(errors.Wrapf(err, "cannot start"))
    32  	}
    33  
    34  	os.Setenv(weaviateEndpoint, compose.GetWeaviate().URI())
    35  	code := m.Run()
    36  
    37  	if err := compose.Terminate(ctx); err != nil {
    38  		panic(errors.Wrapf(err, "cannot terminate"))
    39  	}
    40  
    41  	os.Exit(code)
    42  }