From a39e1ed11804505f84e879ef4a5f4f6fc763c3f2 Mon Sep 17 00:00:00 2001 From: "michel.aquino" Date: Mon, 20 Nov 2023 09:42:09 -0300 Subject: [PATCH] Fix integration test --- api/db/mongo_requests_integration_test.go | 32 +++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/api/db/mongo_requests_integration_test.go b/api/db/mongo_requests_integration_test.go index dd6e4928..99ef56e7 100644 --- a/api/db/mongo_requests_integration_test.go +++ b/api/db/mongo_requests_integration_test.go @@ -873,26 +873,30 @@ var _ = Describe("GetMetricByType", func() { "time_range": {"today"}, } - expectedResult := []bson.M{ - { - "results": []interface{}{ - bson.M{ - "result": "GetMetricByType - result2", - "count": 1, - }, - bson.M{ - "result": "GetMetricByType - result1", - "count": 1, - }, + now := time.Now() + expectedResult := bson.M{ + "results": []interface{}{ + bson.M{ + "result": "GetMetricByType - result2", + "count": 1, + }, + bson.M{ + "result": "GetMetricByType - result1", + "count": 1, }, - "total": 2, - "date": time.Date(2023, 11, 19, 19, 0, 0, 0, time.Local), }, + "total": 2, + "date": time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, time.Local), } metric, errGet := huskydbMongoRequestsTest.GetMetricByType("historyanalysis", queryStringParams) Expect(errGet).To(BeNil()) - Expect(metric).To(ConsistOf(expectedResult)) + + firstMetric := metric.([]bson.M)[0] + + Expect(firstMetric["results"]).To(ConsistOf(expectedResult["results"])) + Expect(firstMetric["total"]).To(Equal(expectedResult["total"])) + Expect(firstMetric["date"]).To(Equal(expectedResult["date"])) }) }) })