Commit 9821a17d authored by Alberto Bertogli's avatar Alberto Bertogli

sts: Use expvar.Int.Value in tests

Now that we raised the minimum Go version to 1.9, we can make use of
expvar's .Value methods to simplify some of the STS tests.

This patch makes those simplifications, which do not change the logic of
the tests themselves.
parent 2943f994
......@@ -7,7 +7,6 @@ import (
......@@ -241,11 +240,9 @@ func TestPolicyTooBig(t *testing.T) {
// Tests for the policy cache.
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)
func expvarMustEq(t *testing.T, name string, v *expvar.Int, expected int64) {
if v.Value() != expected {
t.Errorf("%s is %d, expected %d", name, v.Value(), expected)
......@@ -439,13 +436,11 @@ func TestCacheRefresh(t *testing.T) {
// Launch background refreshes, and wait for one to complete.
// TODO: change to cacheRefreshCycles.Value once we drop support for Go
// 1.7.
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
go c.PeriodicallyRefresh(ctx)
for cacheRefreshCycles.String() == "0" {
for cacheRefreshCycles.Value() == 0 {
time.Sleep(5 * time.Millisecond)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment