Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2021-01-31 19:28:45 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2021-02-03 17:37:47 +0300
commit5f5c0c550f7aa285c2f7981b6fdf57b84c24c504 (patch)
tree8747a2b6a8adafb4d6dfb2242ac0cdcd8fefb677 /internal/testhelper
parent25cb6c09c2ce6ccb81d6f5367eeca0d86d813140 (diff)
Fix usage of the Fatal call
The Fatal function calls os.Exit(1) internally. It leads to immediate process termination and no deferred funcs are called. It is replaced with other option that better applies in the context.
Diffstat (limited to 'internal/testhelper')
-rw-r--r--internal/testhelper/repo.go2
-rw-r--r--internal/testhelper/testhelper.go6
-rw-r--r--internal/testhelper/testserver.go2
3 files changed, 5 insertions, 5 deletions
diff --git a/internal/testhelper/repo.go b/internal/testhelper/repo.go
index a98c6d5ac..e230036cb 100644
--- a/internal/testhelper/repo.go
+++ b/internal/testhelper/repo.go
@@ -114,7 +114,7 @@ func NewTestRepoWithWorktree(t testing.TB) (repo *gitalypb.Repository, repoPath
func testRepositoryPath(t testing.TB) string {
_, currentFile, _, ok := runtime.Caller(0)
if !ok {
- log.Fatal("could not get caller info")
+ require.Fail(t, "could not get caller info")
}
path := filepath.Join(filepath.Dir(currentFile), "..", "..", "_build", "testrepos", "gitlab-test.git")
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index f1d0123d0..389878bca 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -70,7 +70,7 @@ func MustReadFile(t testing.TB, filename string) []byte {
// GitlabTestStoragePath returns the storage path to the gitlab-test repo.
func GitlabTestStoragePath() string {
if testDirectory == "" {
- log.Fatal("you must call testhelper.Configure() before GitlabTestStoragePath()")
+ panic("you must call testhelper.Configure() before GitlabTestStoragePath()")
}
return filepath.Join(testDirectory, "storage")
}
@@ -122,7 +122,7 @@ func MustRunCommand(t testing.TB, stdin io.Reader, name string, args ...string)
if t == nil {
log.Print(name, args)
log.Printf("%s", stderr)
- log.Fatal(err)
+ panic(err)
} else {
t.Log(name, args)
t.Logf("%s", stderr)
@@ -364,7 +364,7 @@ func AssertPathNotExists(t testing.TB, path string) {
// TempDir is a wrapper around ioutil.TempDir that provides a cleanup function.
func TempDir(t testing.TB) (string, func()) {
if testDirectory == "" {
- log.Fatal("you must call testhelper.Configure() before TempDir()")
+ panic("you must call testhelper.Configure() before TempDir()")
}
tmpDir, err := ioutil.TempDir(testDirectory, "")
diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go
index 127854ef1..3d80a3ffa 100644
--- a/internal/testhelper/testserver.go
+++ b/internal/testhelper/testserver.go
@@ -717,7 +717,7 @@ func handlePostReceive(options GitlabTestServerOptions) func(w http.ResponseWrit
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
if err := json.NewEncoder(w).Encode(&response); err != nil {
- log.Fatal(err)
+ panic(err)
}
}
}