Skip to content

Commit 347b552

Browse files
author
wafuwafu13
committed
use runtime.GOROOT()
1 parent d42a117 commit 347b552

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

check-cert-file/lib/check-cert-file_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,26 @@ package checkcertfile
33
import (
44
"os/exec"
55
"path/filepath"
6-
"strings"
6+
"runtime"
77
"testing"
88

99
"github.com/mackerelio/checkers"
1010
"github.com/stretchr/testify/assert"
1111
)
1212

1313
func TestCertFile(t *testing.T) {
14-
goroot, err := exec.Command("go", "env", "GOROOT").Output()
15-
if err != nil {
16-
t.Fatalf("Failed to get GOROOT: %s", err)
17-
}
18-
1914
tmpDir := t.TempDir()
2015
cmd := exec.Command(
2116
"go",
2217
"run",
23-
filepath.FromSlash(filepath.Join(strings.TrimSuffix(string(goroot), "\n"), "/src/crypto/tls/generate_cert.go")),
18+
filepath.FromSlash(filepath.Join(runtime.GOROOT(), "/src/crypto/tls/generate_cert.go")),
2419
"-host",
2520
"localhost",
2621
"-duration",
2722
"720h0m0s", // 30*24*time.Hour
2823
)
2924
cmd.Dir = tmpDir
30-
err = cmd.Run()
25+
err := cmd.Run()
3126
if err != nil {
3227
t.Fatalf("Failed to generate cert.pem: %s", err)
3328
}

0 commit comments

Comments
 (0)