...

Source file src/go.mongodb.org/mongo-driver/mongo/integration/main_test.go

Documentation: go.mongodb.org/mongo-driver/mongo/integration

     1  // Copyright (C) MongoDB, Inc. 2017-present.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
     6  
     7  package integration
     8  
     9  import (
    10  	"flag"
    11  	"log"
    12  	"os"
    13  	"testing"
    14  
    15  	"go.mongodb.org/mongo-driver/mongo/integration/mtest"
    16  )
    17  
    18  func TestMain(m *testing.M) {
    19  	// All tests that use mtest.Setup() are expected to be integration tests, so skip them when the
    20  	// -short flag is included in the "go test" command. Also, we have to parse flags here to use
    21  	// testing.Short() because flags aren't parsed before TestMain() is called.
    22  	flag.Parse()
    23  	if testing.Short() {
    24  		log.Print("skipping mtest integration test in short mode")
    25  		return
    26  	}
    27  
    28  	if err := mtest.Setup(); err != nil {
    29  		log.Fatal(err)
    30  	}
    31  	defer os.Exit(m.Run())
    32  	if err := mtest.Teardown(); err != nil {
    33  		log.Fatal(err)
    34  	}
    35  }
    36  

View as plain text