git » chasquid » commit cb6500b

sts: Don't use expvar.Int.Value in tests, for Go 1.7 compatibility

author Alberto Bertogli
2017-03-01 10:14:39 UTC
committer Alberto Bertogli
2017-03-01 10:14:39 UTC
parent f1b9d9e68a48f83bde42a67c0531681196758893

sts: Don't use expvar.Int.Value in tests, for Go 1.7 compatibility

expvar.Int.Value appeared in Go 1.8, but we want to keep compatibility
with Go 1.7 at least until the next release.

So this patch replaces the use of expvar.Int.Value in tests, to make
them compatible with Go 1.7 again.

internal/sts/sts_test.go +4 -2

diff --git a/internal/sts/sts_test.go b/internal/sts/sts_test.go
index 0b74906..bc26940 100644
--- a/internal/sts/sts_test.go
+++ b/internal/sts/sts_test.go
@@ -8,6 +8,7 @@ import (
 	"net/http"
 	"net/http/httptest"
 	"os"
+	"strconv"
 	"testing"
 	"time"
 )
@@ -191,8 +192,9 @@ func mustTempDir(t *testing.T) string {
 	return dir
 }
 
-func expvarMustEq(t *testing.T, name string, v *expvar.Int, expected int64) {
-	value := v.Value()
+func expvarMustEq(t *testing.T, name string, v *expvar.Int, expected int) {
+	// TODO: Use v.Value once we drop support of Go 1.7.
+	value, _ := strconv.Atoi(v.String())
 	if value != expected {
 		t.Errorf("%s is %d, expected %d", name, value, expected)
 	}