From fc1cb173fc50dc7f76084873c5e34f07a84c258a Mon Sep 17 00:00:00 2001 From: Charles Daniels Date: Mon, 13 Sep 2021 22:59:23 -0400 Subject: [PATCH] fix flaky CSV test verified with go test -run=Test_CSV -count=1000 ./ The fix was simply to explicitly specify the order of columns in the SELECT query. --- logquery_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/logquery_test.go b/logquery_test.go index e326513..3de2905 100644 --- a/logquery_test.go +++ b/logquery_test.go @@ -78,14 +78,12 @@ event=error code=456 msg="something went wrong" timestamp="1970-01-01 18:56" fla } func Test_CSV(t *testing.T) { - // TODO: this test is flaky because the keys can be in potentially any - // order. - input := "c1=5 c2=true c3=3.4\nc1=3 c2=false c3=5.1" inputReader := strings.NewReader(input) buf := bytes.NewBufferString("") - err := RunQuery(inputReader, buf, "SELECT * FROM log;", CSV) + // We use an explicit list of columns so as to guarantee their order. + err := RunQuery(inputReader, buf, "SELECT c1,c2,c3 FROM log;", CSV) assert.Nil(t, err) assert.Equal(t, "c1,c2,c3\n5,true,3.4\n3,false,5.1\n", buf.String()) -- 2.45.2