github.com/mattermost/mattermost-server/server/v8@v8.0.0-20230610055354-a6d1d38b273d/platform/services/slackimport/main_test.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package slackimport
     5  
     6  import (
     7  	"fmt"
     8  	"os"
     9  	"testing"
    10  )
    11  
    12  func TestMain(m *testing.M) {
    13  	prevDir, err := os.Getwd()
    14  	if err != nil {
    15  		panic("Failed to get current working directory: " + err.Error())
    16  	}
    17  
    18  	err = os.Chdir("../..")
    19  	if err != nil {
    20  		panic(fmt.Sprintf("Failed to set current working directory to %s: %s", "../..", err.Error()))
    21  	}
    22  
    23  	defer func() {
    24  		err := os.Chdir(prevDir)
    25  		if err != nil {
    26  			panic(fmt.Sprintf("Failed to restore current working directory to %s: %s", prevDir, err.Error()))
    27  		}
    28  	}()
    29  
    30  	os.Exit(m.Run())
    31  }