Skip to content

Commit

Permalink
Fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
michel.aquino committed Nov 20, 2023
1 parent d818f5b commit a39e1ed
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions api/db/mongo_requests_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"]))
})
})
})

0 comments on commit a39e1ed

Please sign in to comment.