From c5baf43745a1aa8e961be7d4bf75dace6522c374 Mon Sep 17 00:00:00 2001 From: Goutham Veeramachaneni Date: Tue, 18 Aug 2020 12:56:00 +0200 Subject: [PATCH] Make tests build on go1.15 (#3052) My machine was upgraded to go1.15 and tests were failing with "conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)" Signed-off-by: Goutham Veeramachaneni --- cache/memcached_test.go | 19 ++++++++++--------- schema_test.go | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cache/memcached_test.go b/cache/memcached_test.go index ee5596f2afd50..70b18fd4a7666 100644 --- a/cache/memcached_test.go +++ b/cache/memcached_test.go @@ -3,6 +3,7 @@ package cache_test import ( "context" "errors" + "fmt" "testing" "github.com/bradfitz/gomemcache/memcache" @@ -43,26 +44,26 @@ func testMemcache(t *testing.T, memcache *cache.Memcached) { // Insert 1000 keys skipping all multiples of 5. for i := 0; i < numKeys; i++ { - keysIncMissing = append(keysIncMissing, string(i)) + keysIncMissing = append(keysIncMissing, fmt.Sprint(i)) if i%5 == 0 { continue } - keys = append(keys, string(i)) - bufs = append(bufs, []byte(string(i))) + keys = append(keys, fmt.Sprint(i)) + bufs = append(bufs, []byte(fmt.Sprint(i))) } memcache.Store(ctx, keys, bufs) found, bufs, missing := memcache.Fetch(ctx, keysIncMissing) for i := 0; i < numKeys; i++ { if i%5 == 0 { - require.Equal(t, string(i), missing[0]) + require.Equal(t, fmt.Sprint(i), missing[0]) missing = missing[1:] continue } - require.Equal(t, string(i), found[0]) - require.Equal(t, string(i), string(bufs[0])) + require.Equal(t, fmt.Sprint(i), found[0]) + require.Equal(t, fmt.Sprint(i), string(bufs[0])) found = found[1:] bufs = bufs[1:] } @@ -118,12 +119,12 @@ func testMemcacheFailing(t *testing.T, memcache *cache.Memcached) { bufs := make([][]byte, 0, numKeys) // Insert 1000 keys skipping all multiples of 5. for i := 0; i < numKeys; i++ { - keysIncMissing = append(keysIncMissing, string(i)) + keysIncMissing = append(keysIncMissing, fmt.Sprint(i)) if i%5 == 0 { continue } - keys = append(keys, string(i)) - bufs = append(bufs, []byte(string(i))) + keys = append(keys, fmt.Sprint(i)) + bufs = append(bufs, []byte(fmt.Sprint(i))) } memcache.Store(ctx, keys, bufs) diff --git a/schema_test.go b/schema_test.go index fd7ef57c36280..9386b6c884858 100644 --- a/schema_test.go +++ b/schema_test.go @@ -409,8 +409,8 @@ func TestV10IndexQueries(t *testing.T) { res = append(res, IndexQuery{ TableName: "tbl", HashValue: fmt.Sprintf("%02d:%s:%s:%s", i, "hash", "metric", "label"), - RangeValueStart: []byte(string(i)), - ValueEqual: []byte(string(i)), + RangeValueStart: []byte(fmt.Sprint(i)), + ValueEqual: []byte(fmt.Sprint(i)), }) } return res