Skip to content

Commit

Permalink
added test for JSON formatted context
Browse files Browse the repository at this point in the history
  • Loading branch information
skreutzberger committed Jun 22, 2017
1 parent e798f60 commit 78a5598
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ disabled_rules: # rule identifiers to exclude from running
- function_parameter_count
- implicit_getter

line_length: 150
line_length: 200

type_name:
min_length: 2
Expand Down
7 changes: 5 additions & 2 deletions Tests/SwiftyBeaverTests/BaseDestinationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class BaseDestinationTests: XCTestCase {
func testMessageToJSON() {
let obj = BaseDestination()
guard let str = obj.messageToJSON(.info, msg: "hello world", thread: "main",
file: "/path/to/ViewController.swift", function: "testFunction()", line: 50) else {
file: "/path/to/ViewController.swift", function: "testFunction()", line: 50, context: ["foo": "bar", "hello": 2]) else {
XCTFail("str should not be nil"); return
}
print(str)
Expand All @@ -123,7 +123,8 @@ class BaseDestinationTests: XCTestCase {
let thread = dict["thread"] as? String,
let file = dict["file"] as? String,
let function = dict["function"] as? String,
let line = dict["line"] as? Int else {
let line = dict["line"] as? Int,
let context = dict["context"] as? [String: Any] else {
XCTFail("dict and its properties should not be nil"); return
}
XCTAssertGreaterThanOrEqual(timestamp, Date().timeIntervalSince1970 - 10)
Expand All @@ -133,6 +134,8 @@ class BaseDestinationTests: XCTestCase {
XCTAssertEqual(file, "/path/to/ViewController.swift")
XCTAssertEqual(function, "testFunction()")
XCTAssertEqual(line, 50)
XCTAssertEqual(context["foo"] as? String, "bar")
XCTAssertEqual(context["hello"] as? Int, 2)
}

func testLevelWord() {
Expand Down

0 comments on commit 78a5598

Please sign in to comment.