Skip to content

Commit

Permalink
Fix webhook test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZekeSnider committed Aug 18, 2020
1 parent e62762d commit 526f68c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Jared.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
B36C8D7F24EA655900C00A99 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = B36C8D7E24EA655900C00A99 /* Configuration.swift */; };
B375A65921EB14470073F09F /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B375A65821EB14470073F09F /* AboutViewController.swift */; };
B37E82821FA85B210069E15D /* SendTextSingleBuddy.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B37E82811FA85B210069E15D /* SendTextSingleBuddy.scpt */; };
B38BB6AD24EB99BE000700F7 /* Webhook.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B7E52824EA579600A3FBD1 /* Webhook.swift */; };
B39A65E01CC1FB1B003E26B0 /* PluginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39A65DF1CC1FB1B003E26B0 /* PluginManager.swift */; };
B39F2B391CB3BCA700C0D35C /* SendText.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B39F2B381CB3BCA700C0D35C /* SendText.scpt */; };
B3A4C61423B867E300B7F009 /* MessageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A4C61323B867E300B7F009 /* MessageRequest.swift */; };
Expand Down Expand Up @@ -836,6 +837,7 @@
B347A4AD24DD170C00E93657 /* ActionTest.swift in Sources */,
B36710E224DFB5EC00DA1C5D /* JaredMock.swift in Sources */,
B3B844C224D8FA7D00DC162A /* DatabaseTestHelper.swift in Sources */,
B38BB6AD24EB99BE000700F7 /* Webhook.swift in Sources */,
B3B844BA24D77A4900DC162A /* SendStyleTest.swift in Sources */,
B3327DD8220682ED009DD882 /* WebhookTests.swift in Sources */,
B3EF1DB02206E4EB00953DE7 /* MessageTests.swift in Sources */,
Expand Down
8 changes: 6 additions & 2 deletions JaredTests/WebhookTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class WebhookTests: XCTestCase {
let SAMPLE_MESSAGE = Message(body: TextBody("hello there jared"), date: Date(timeIntervalSince1970: TimeInterval(1495061841)), sender: Person(givenName: "zeke", handle: "[email protected]", isMe: true), recipient: Person(givenName: "jared", handle: "[email protected]", isMe: false))

var config: URLSessionConfiguration!
var sender: JaredMock!

override func setUp() {
config = URLSessionConfiguration.ephemeral
config.protocolClasses = [URLProtocolMock.self]
sender = JaredMock()
}

override func tearDown() {
Expand All @@ -30,7 +32,9 @@ class WebhookTests: XCTestCase {
// set up first call to webhook with one url
let url = URL(string: WEBHOOK_TEST_URL)
URLProtocolMock.testURLs = [url: Data(MESSAGE_SERIALIZED.utf8)]
let webhookManager = WebHookManager(webhooks: [WEBHOOK_TEST_URL], session: config)
let webhook = Webhook(url: WEBHOOK_TEST_URL, routes: [])
let webhookTwo = Webhook(url: WEBHOOK_TEST_URL_TWO, routes: [])
let webhookManager = WebHookManager(webhooks: [webhook], session: config, sender: sender)

webhookManager.didProcess(message: SAMPLE_MESSAGE)

Expand All @@ -42,7 +46,7 @@ class WebhookTests: XCTestCase {

// setup for second call which adds another url to the webhook
// list
webhookManager.updateHooks(to: [WEBHOOK_TEST_URL, WEBHOOK_TEST_URL_TWO])
webhookManager.updateHooks(to: [webhook, webhookTwo])
let urlTwo = URL(string: WEBHOOK_TEST_URL_TWO)
URLProtocolMock.testURLs = [
url: Data(MESSAGE_SERIALIZED.utf8),
Expand Down

0 comments on commit 526f68c

Please sign in to comment.