Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Feb 26, 2023
1 parent a0688ff commit 161df2d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions elton_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"net/http"
"net/http/httptest"
"os"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -608,18 +607,15 @@ func TestGracefulClose(t *testing.T) {

// https://stackoverflow.com/questions/50120427/fail-unit-tests-if-coverage-is-below-certain-percentage
func TestMain(m *testing.M) {
// call flag.Parse() here if TestMain uses flags
// go 1.20获取到Coverage为0
if runtime.Version() == "go1.20" {
return
}
rc := m.Run()

// rc 0 means we've passed,
// and CoverMode will be non empty if run with -cover
if rc == 0 && testing.CoverMode() != "" {
c := testing.Coverage()
if c < 0.9 {
// TODO 后续处理
// go 1.20获取到Coverage为0
if c != 0 && c < 0.9 {
fmt.Println("Tests passed but coverage failed at", c)
rc = -1
}
Expand Down

0 comments on commit 161df2d

Please sign in to comment.