Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Respond to #12 review comments #14

Merged
merged 5 commits into from
Oct 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
source 'https://github.com/CocoaPods/Specs'
use_frameworks!

target 'PureeTests' do
pod "Puree", :path => "../"
Expand Down
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PODS:
- CocoaLumberjack/Core
- CocoaLumberjack/Extensions (2.4.0):
- CocoaLumberjack/Default
- Puree (1.1.0):
- Puree (2.0.0):
- YapDatabase (~> 2.9.2)
- Reachability (3.2)
- YapDatabase (2.9.2):
Expand Down Expand Up @@ -70,10 +70,10 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
CocoaLumberjack: aa9dcab71bdf9eaf2a63bbd9ddc87863efe45457
Puree: a71cf999f4bb504c2ed3257dbabc7377aaaac699
Puree: dce923c586654f0b301801a2aecb6917cf6f8e82
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f

PODFILE CHECKSUM: ac4495e7212e7848dc39e4702fb4f7622665bd74
PODFILE CHECKSUM: af5047754632caf7b29086116f921595e64a2970

COCOAPODS: 1.1.0.rc.2
8 changes: 4 additions & 4 deletions Example/Puree.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
5760F1D41BB7CD26009A143D /* PURTestOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5760F1CC1BB7CD26009A143D /* PURTestOutput.swift */; };
5760F1D51BB7CD26009A143D /* TestLogStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5760F1CD1BB7CD26009A143D /* TestLogStorage.swift */; };
57ABD6DC1D979CE300B3B52D /* PURLoggerStandardPluginTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57ABD6DB1D979CE300B3B52D /* PURLoggerStandardPluginTest.swift */; };
63558BFD2171AF61402ECA48 /* Pods_PureeTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 501F680AA62C916D4E54EF9E /* Pods_PureeTests.framework */; };
9F6C6315B68326F76296B9BF /* libPods-PureeTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F114EB7406FEADE718D7A6E5 /* libPods-PureeTests.a */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
2D02199567B505DD66CAAACC /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
501F680AA62C916D4E54EF9E /* Pods_PureeTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PureeTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5760F1B91BB7CBFC009A143D /* PureeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PureeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5760F1BD1BB7CBFD009A143D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5760F1C11BB7CC7C009A143D /* PureeTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PureeTests-Bridging-Header.h"; sourceTree = "<group>"; };
Expand All @@ -41,14 +40,15 @@
6412CE7C1B65D0BBA34A4332 /* Puree.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Puree.podspec; path = ../Puree.podspec; sourceTree = "<group>"; };
A74A5DDA68461D97C2E89F24 /* Pods-PureeTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PureeTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PureeTests/Pods-PureeTests.debug.xcconfig"; sourceTree = "<group>"; };
D7F43655475AA82E9B4A327D /* Pods-PureeTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PureeTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-PureeTests/Pods-PureeTests.release.xcconfig"; sourceTree = "<group>"; };
F114EB7406FEADE718D7A6E5 /* libPods-PureeTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PureeTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
5760F1B61BB7CBFC009A143D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
63558BFD2171AF61402ECA48 /* Pods_PureeTests.framework in Frameworks */,
9F6C6315B68326F76296B9BF /* libPods-PureeTests.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -116,7 +116,7 @@
6003F58F195388D20070C39A /* CoreGraphics.framework */,
6003F591195388D20070C39A /* UIKit.framework */,
6003F5AF195388D20070C39A /* XCTest.framework */,
501F680AA62C916D4E54EF9E /* Pods_PureeTests.framework */,
F114EB7406FEADE718D7A6E5 /* libPods-PureeTests.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down
41 changes: 24 additions & 17 deletions Example/Tests/PURLogStoreTest.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Puree
import XCTest

class PURLogStoreTest: XCTestCase {
Expand All @@ -25,10 +24,10 @@ class PURLogStoreTest: XCTestCase {
logStore.clearAll()
}

func assertLogStoreLogCount(pattern: String, output: PUROutput, expectedCount: Int, line: Int = #line) {
func assertLogCount(of output: PUROutput, expectedCount: Int, line: Int = #line) {
let countExpectation = expectation(description: "log count")
var count = -1
logStore.retrieveLogs(forPattern: pattern, output:output) { logs in
logStore.retrieveLogs(for: output) { logs in
count = logs.count
countExpectation.fulfill()
}
Expand All @@ -38,16 +37,17 @@ class PURLogStoreTest: XCTestCase {

func addTestLog(_ log: PURLog, output: PUROutput, description: String) {
let addExpectation = expectation(description: description)
logStore.add(log, from: output) { addExpectation.fulfill() }
logStore.add(log, for: output) { addExpectation.fulfill() }
}

func addTestLogs(_ logs: [PURLog], output: PUROutput, description: String) {
let addExpectation = expectation(description: description)
logStore.add(logs, from: output) { addExpectation.fulfill() }
logStore.add(logs, for: output) { addExpectation.fulfill() }
}

func testAddLog() {
assertLogStoreLogCount(pattern: "test.*", output: outputA, expectedCount: 0)
assertLogCount(of: outputA, expectedCount: 0)
assertLogCount(of: outputB, expectedCount: 0)

addTestLog(PURLog(tag: "test.apple", date: Date(), userInfo: [:]), output: outputA, description: "add test log 1")
addTestLog(PURLog(tag: "test.apple", date: Date(), userInfo: [:]), output: outputA, description: "add test log 2")
Expand All @@ -57,11 +57,13 @@ class PURLogStoreTest: XCTestCase {

waitForExpectations(timeout: 1.0, handler: nil)

assertLogStoreLogCount(pattern: "test.*", output: outputA, expectedCount: 4)
assertLogCount(of: outputA, expectedCount: 4)
assertLogCount(of: outputB, expectedCount: 1)
}

func testAddLogs() {
assertLogStoreLogCount(pattern: "test.*", output: outputA, expectedCount: 0)
assertLogCount(of: outputA, expectedCount: 0)
assertLogCount(of: outputB, expectedCount: 0)

addTestLogs([
PURLog(tag: "test.apple", date: Date(), userInfo: [:]),
Expand All @@ -78,7 +80,8 @@ class PURLogStoreTest: XCTestCase {

waitForExpectations(timeout: 1.0, handler: nil)

assertLogStoreLogCount(pattern: "test.*", output: outputA, expectedCount: 5)
assertLogCount(of: outputA, expectedCount: 5)
assertLogCount(of: outputB, expectedCount: 2)
}

func testRemoveLogs() {
Expand All @@ -102,19 +105,23 @@ class PURLogStoreTest: XCTestCase {

waitForExpectations(timeout: 1.0, handler: nil)

assertLogStoreLogCount(pattern: "test.*", output: outputA, expectedCount: 5)
assertLogStoreLogCount(pattern: "test.*", output: outputB, expectedCount: 2)
assertLogCount(of: outputA, expectedCount: 5)
assertLogCount(of: outputB, expectedCount: 2)

let removeExpectation = expectation(description: "remove logs")
logStore.remove(firstChunk, from: outputA) { removeExpectation.fulfill() }
logStore.remove(firstChunk, for: outputA) { removeExpectation.fulfill() }

waitForExpectations(timeout: 1.0, handler: nil)

assertLogStoreLogCount(pattern: "test.*", output: outputA, expectedCount: 3)
assertLogStoreLogCount(pattern: "test.*", output: outputB, expectedCount: 2)
assertLogCount(of: outputA, expectedCount: 3)
assertLogCount(of: outputB, expectedCount: 2)
}

func testStressTest() {
assertLogCount(of: outputA, expectedCount: 0)
assertLogCount(of: outputB, expectedCount: 0)
assertLogCount(of: outputC, expectedCount: 0)

// write (3 + 3 + 4) * 100 logs (1000 logs)
for i in 1...100 {
addTestLogs([
Expand Down Expand Up @@ -143,8 +150,8 @@ class PURLogStoreTest: XCTestCase {
}
waitForExpectations(timeout: 8.0, handler: nil)

assertLogStoreLogCount(pattern: "testA.*", output: outputA, expectedCount: 300)
assertLogStoreLogCount(pattern: "testB.*", output: outputB, expectedCount: 300)
assertLogStoreLogCount(pattern: "testC.*", output: outputC, expectedCount: 1400)
assertLogCount(of: outputA, expectedCount: 300)
assertLogCount(of: outputB, expectedCount: 300)
assertLogCount(of: outputC, expectedCount: 1400)
}
}
Loading