github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/cmd/hkserver/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/masterhung0112/hk_server/v5/api4"
    12  	"github.com/masterhung0112/hk_server/v5/shared/mlog"
    13  	"github.com/masterhung0112/hk_server/v5/testlib"
    14  )
    15  
    16  func TestMain(m *testing.M) {
    17  	// Command tests are run by re-invoking the test binary in question, so avoid creating
    18  	// another container when we detect same.
    19  	flag.Parse()
    20  	if filter := flag.Lookup("test.run").Value.String(); filter == "ExecCommand" {
    21  		status := m.Run()
    22  		os.Exit(status)
    23  		return
    24  	}
    25  
    26  	var options = testlib.HelperOptions{
    27  		EnableStore:     true,
    28  		EnableResources: true,
    29  	}
    30  
    31  	mlog.DisableZap()
    32  
    33  	mainHelper = testlib.NewMainHelperWithOptions(&options)
    34  	defer mainHelper.Close()
    35  	api4.SetMainHelper(mainHelper)
    36  
    37  	mainHelper.Main(m)
    38  }