From 00de56a4a4ebacaa7ad2f18fb7d427a88efa82e9 Mon Sep 17 00:00:00 2001 From: Piotr Tabor Date: Tue, 4 Aug 2020 13:18:49 +0200 Subject: [PATCH] etcdserver, wal: Fix tests that were performing unintended casting of int to String. Fixes following problems during "./etcd# go test ./..." > go.etcd.io/etcd/v3/etcdserver/api/v2store_test etcdserver/api/v2store/store_test.go:847:24: conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?) > go.etcd.io/etcd/v3/wal wal/wal_test.go:242:68: conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?) --- etcdserver/api/v2store/store_test.go | 3 ++- wal/wal_test.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/etcdserver/api/v2store/store_test.go b/etcdserver/api/v2store/store_test.go index 76ec02d4e8d..dba010be4bb 100644 --- a/etcdserver/api/v2store/store_test.go +++ b/etcdserver/api/v2store/store_test.go @@ -15,6 +15,7 @@ package v2store_test import ( + "fmt" "testing" "time" @@ -844,7 +845,7 @@ func TestStoreWatchSlowConsumer(t *testing.T) { s.Watch("/foo", true, true, 0) // stream must be true // Fill watch channel with 100 events for i := 1; i <= 100; i++ { - s.Set("/foo", false, string(i), v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) // ok + s.Set("/foo", false, fmt.Sprint(i), v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) // ok } // testutil.AssertEqual(t, s.WatcherHub.count, int64(1)) s.Set("/foo", false, "101", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) // ok diff --git a/wal/wal_test.go b/wal/wal_test.go index f457dbf3c43..5aa085f0ce5 100644 --- a/wal/wal_test.go +++ b/wal/wal_test.go @@ -239,7 +239,7 @@ func TestVerify(t *testing.T) { // make 5 separate files for i := 0; i < 5; i++ { - es := []raftpb.Entry{{Index: uint64(i), Data: []byte("waldata" + string(i+1))}} + es := []raftpb.Entry{{Index: uint64(i), Data: []byte(fmt.Sprintf("waldata%d", i+1))}} if err = w.Save(raftpb.HardState{}, es); err != nil { t.Fatal(err) }