mirror of https://github.com/go-gitea/gitea.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
858 B
40 lines
858 B
// Copyright 2025 The Gitea Authors. All rights reserved. |
|
// SPDX-License-Identifier: MIT |
|
|
|
package attribute |
|
|
|
import ( |
|
"fmt" |
|
"os" |
|
"testing" |
|
|
|
"code.gitea.io/gitea/modules/git" |
|
"code.gitea.io/gitea/modules/setting" |
|
"code.gitea.io/gitea/modules/util" |
|
) |
|
|
|
func testRun(m *testing.M) error { |
|
gitHomePath, err := os.MkdirTemp(os.TempDir(), "git-home") |
|
if err != nil { |
|
return fmt.Errorf("unable to create temp dir: %w", err) |
|
} |
|
defer util.RemoveAll(gitHomePath) |
|
setting.Git.HomePath = gitHomePath |
|
|
|
if err = git.InitFull(); err != nil { |
|
return fmt.Errorf("failed to call Init: %w", err) |
|
} |
|
|
|
exitCode := m.Run() |
|
if exitCode != 0 { |
|
return fmt.Errorf("run test failed, ExitCode=%d", exitCode) |
|
} |
|
return nil |
|
} |
|
|
|
func TestMain(m *testing.M) { |
|
if err := testRun(m); err != nil { |
|
_, _ = fmt.Fprintf(os.Stderr, "Test failed: %v", err) |
|
os.Exit(1) |
|
} |
|
}
|
|
|