github.com/mattermosttest/mattermost-server/v5@v5.0.0-20200917143240-9dfa12e121f9/cmd/mattermost/commands/main_test.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package commands
     5  
     6  import (
     7  	"flag"
     8  	"os"
     9  	"testing"
    10  
    11  	"github.com/mattermost/mattermost-server/v5/api4"
    12  	"github.com/mattermost/mattermost-server/v5/testlib"
    13  )
    14  
    15  func TestMain(m *testing.M) {
    16  	// Command tests are run by re-invoking the test binary in question, so avoid creating
    17  	// another container when we detect same.
    18  	flag.Parse()
    19  	if filter := flag.Lookup("test.run").Value.String(); filter == "ExecCommand" {
    20  		status := m.Run()
    21  		os.Exit(status)
    22  		return
    23  	}
    24  
    25  	var options = testlib.HelperOptions{
    26  		EnableStore:     true,
    27  		EnableResources: true,
    28  	}
    29  
    30  	mainHelper = testlib.NewMainHelperWithOptions(&options)
    31  	defer mainHelper.Close()
    32  	api4.SetMainHelper(mainHelper)
    33  
    34  	mainHelper.Main(m)
    35  }