-
Notifications
You must be signed in to change notification settings - Fork 21
fix: update health routes to be codable #472
fix: update health routes to be codable #472
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #472 +/- ##
========================================
Coverage 90.61% 90.61%
========================================
Files 9 9
Lines 1343 1343
========================================
Hits 1217 1217
Misses 126 126 Continue to review full report at Codecov.
|
if let getResult = String(data: data, encoding: String.Encoding.utf8) { | ||
XCTAssertEqual(statusCode, 200) | ||
XCTAssertTrue(getResult.contains("UP")) | ||
XCTAssertTrue(getResult.contains("2017") || getResult.contains("2018") || getResult.contains("2019")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a more dynamic timestamp check here? This will be a pain to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to dynamically get the current year and make a check that its the same as returned in the test.
let yearString = String(describing: calendar.component(.year, from: date)) | ||
XCTAssertTrue(getResult.contains(yearString) | ||
} else { | ||
XCTFail("Return value from /health was nil, or was not UP, or had no timestamp.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this error message doesn't give correct information about the error.
It is better to put the errors inside the asserts such as :
XCTAssertEqual(statusCode, 200, "Error")
And set this XCTFail to "The conversion to String(..) failed" something along those lines which is what the if
is checking for.
let date = Date() | ||
let calendar = Calendar.current | ||
let yearString = String(describing: calendar.component(.year, from: date)) | ||
XCTAssertTrue(getResult.contains(yearString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there is a parentheses missing here
@KyeMaloy97 Can you address the concerns above? |
…tserver into updateHealthRoutes
* fix(package): update generator-ibm-cloud-enablement to version 0.12.0 Closes #484 * Adding xunit-file and updating package.json to run mocha * chore(devops-insights): Updating commit message * fix: update health routes to be codable (#472) * fix: updated health routes to use codable * chore(release): 4.9.2
Updated the health routes file to leverage codable routing, no regression as the behavior is the same as before, it returns two items if theres an issue and one if there isn't.