From c66c4e1b933766050d717dacd9c1eba54a511b44 Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Sun, 8 May 2022 11:03:24 +0300 Subject: [PATCH] Fix the tests --- client/go/client_test.go | 6 +++--- server/server_test.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/client/go/client_test.go b/client/go/client_test.go index 32cda53..9d19272 100644 --- a/client/go/client_test.go +++ b/client/go/client_test.go @@ -155,11 +155,11 @@ func TestFetch(t *testing.T) { data, firstMeta, lastMeta, err := Fetch(HOST, PORT, fmt.Sprintf("%024d", 100), -1, `chevy`, 20, 20*time.Second) assert.Nil(t, err) - assert.Equal(t, fmt.Sprintf(`{"current":1,"total":15000,"numberOfWritten":0,"leftOff":"%s","truncatedTimestamp":0,"noMoreData":false}`, fmt.Sprintf("%024d", 98)), string(firstMeta)) - assert.Equal(t, fmt.Sprintf(`{"current":20,"total":15000,"numberOfWritten":19,"leftOff":"%s","truncatedTimestamp":0,"noMoreData":false}`, fmt.Sprintf("%024d", 79)), string(lastMeta)) + assert.Equal(t, fmt.Sprintf(`{"current":1,"total":15000,"numberOfWritten":0,"leftOff":"%s","truncatedTimestamp":0,"noMoreData":false}`, fmt.Sprintf("%024d", 99)), string(firstMeta)) + assert.Equal(t, fmt.Sprintf(`{"current":20,"total":15000,"numberOfWritten":19,"leftOff":"%s","truncatedTimestamp":0,"noMoreData":false}`, fmt.Sprintf("%024d", 80)), string(lastMeta)) i := 0 - for id := 99; id > 80; id-- { + for id := 100; id > 80; id-- { expected := fmt.Sprintf(`{"brand":{"name":"Chevrolet"},"id":"%s","model":"Camaro","year":"%s"}`, fmt.Sprintf("%024d", id-1), REDACTED) assert.JSONEq(t, expected, string(data[i])) i++ diff --git a/server/server_test.go b/server/server_test.go index faa013e..28c58d9 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -451,12 +451,6 @@ func TestServerProtocolFetchMode(t *testing.T) { break } - if row.direction < 0 { - index-- - } else { - index++ - } - if index >= total || index < 0 { return } @@ -464,6 +458,12 @@ func TestServerProtocolFetchMode(t *testing.T) { expected := fmt.Sprintf(`{"brand":{"name":"Chevrolet"},"id":"%s","model":"Camaro","year":2021}`, basenine.IndexToID(index)) assert.JSONEq(t, expected, string(bytes)) + if row.direction < 0 { + index-- + } else { + index++ + } + counter++ if counter >= row.expected {