Skip to content

Conversation

@pedantix
Copy link
Member

@tanner0101 sorry about the terrible confusion

@pedantix pedantix requested a review from tanner0101 April 25, 2018 21:07
func testUnlisten() throws {
let completionHandlerExpectation = expectation(description: "notify completion handler called")
completionHandlerExpectation.expectedFulfillmentCount = 2
completionHandlerExpectation.assertForOverFulfill = true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MrMage do you know of an alternative for these guys on Linux?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid not :-/ I normally solve this by storing all the results provided to the callback handler in a separate array, and once I’ve waited for all expectations, I Test the array‘s contents using regular XCTest methods.

@tanner0101 tanner0101 merged commit f6e0804 into vapor:dbkit-gm Apr 25, 2018
_ = executeCloseHandlersThenClose()
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not: extra newline and two spaces before „func“

let listenConn = try PostgreSQLConnection.makeTest()
let channelName = "Foo"
let channelName = "Fooze"
let messageText = "Bar"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: also test with a message text longer than 3 characters, and test with an empty message? (See above.)

self.message = message ?? channelId
_ = try container.decode(Int32.self)
channel = try container.decode(String.self)
message = try container.decode(String.self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postgres allows for now message to be provided, so I think message should be an optional and this an optional decode? Or will the message simply be empty in that case? (At least worth testing.)

let query = PostgreSQLQuery(query: "NOTIFY \"\(channelName)\", '\(message)';")
return send([.query(query)]).map(to: Void.self, { _ in })
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postgres‘ notify command allows omitting the payload, so how about allowingNil messages in notify?

unlistenHandlerExpectation.fulfill()
}).wait()
waitForExpectations(timeout: defaultTimeout)
notifyConn.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also test that no further notifications are sent after unlisten has been called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants