-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #633 from snowplow/release/2.2.2
Release/2.2.2
- Loading branch information
Showing
20 changed files
with
680 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// TestDataPersistence.m | ||
// Snowplow-iOSTests | ||
// | ||
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License | ||
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on | ||
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the Apache License Version 2.0 for the specific | ||
// language governing permissions and limitations there under. | ||
// | ||
// Authors: Alex Benini | ||
// Copyright: Copyright (c) 2013-2021 Snowplow Analytics Ltd | ||
// License: Apache License Version 2.0 | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
#import "SPDataPersistence.h" | ||
|
||
@interface TestDataPersistence : XCTestCase | ||
|
||
@end | ||
|
||
@implementation TestDataPersistence | ||
|
||
- (void)setUp { | ||
[SPDataPersistence removeDataPersistenceWithNamespace:@"namespace"]; | ||
[SPDataPersistence removeDataPersistenceWithNamespace:@"namespace1"]; | ||
[SPDataPersistence removeDataPersistenceWithNamespace:@"namespace2"]; | ||
} | ||
|
||
- (void)testStringFromNamespace { | ||
XCTAssertEqualObjects(@"abc-1_2_3", [SPDataPersistence stringFromNamespace:@"abc 1_2_3"]); | ||
} | ||
|
||
- (void)testDataPersistenceForNamespaceWithDifferentNamespaces { | ||
SPDataPersistence *dp1 = [SPDataPersistence dataPersistenceForNamespace:@"namespace1"]; | ||
SPDataPersistence *dp2 = [SPDataPersistence dataPersistenceForNamespace:@"namespace2"]; | ||
XCTAssertNotEqual(dp1, dp2); | ||
} | ||
|
||
- (void)testDataPersistenceForNamespaceWithSameNamespaces { | ||
SPDataPersistence *dp1 = [SPDataPersistence dataPersistenceForNamespace:@"namespace"]; | ||
SPDataPersistence *dp2 = [SPDataPersistence dataPersistenceForNamespace:@"namespace"]; | ||
XCTAssertEqual(dp1, dp2); | ||
} | ||
|
||
- (void)testRemoveDataPersistenceForNamespace { | ||
SPDataPersistence *dp1 = [SPDataPersistence dataPersistenceForNamespace:@"namespace"]; | ||
[SPDataPersistence removeDataPersistenceWithNamespace:@"namespace"]; | ||
SPDataPersistence *dp2 = [SPDataPersistence dataPersistenceForNamespace:@"namespace"]; | ||
XCTAssertNotEqual(dp1, dp2); | ||
} | ||
|
||
- (void)testDataIsCorrectlyStored { | ||
SPDataPersistence *dp = [SPDataPersistence dataPersistenceForNamespace:@"namespace"]; | ||
NSDictionary<NSString *, NSObject *> *session = @{@"key": @"value"}; | ||
dp.session = session; | ||
XCTAssertEqualObjects(session, dp.session); | ||
XCTAssertEqualObjects(session, dp.data[@"session"]); | ||
// Override session | ||
session = @{@"key2": @"value2"}; | ||
dp.session = session; | ||
XCTAssertEqualObjects(session, dp.session); | ||
XCTAssertEqualObjects(session, dp.data[@"session"]); | ||
} | ||
|
||
- (void)testDataIsStoredWithoutInterference { | ||
SPDataPersistence *dp1 = [SPDataPersistence dataPersistenceForNamespace:@"namespace1"]; | ||
SPDataPersistence *dp2 = [SPDataPersistence dataPersistenceForNamespace:@"namespace2"]; | ||
NSDictionary<NSString *, NSObject *> *session = @{@"key": @"value"}; | ||
dp1.session = session; | ||
// Check dp1 | ||
XCTAssertEqualObjects(session, dp1.session); | ||
XCTAssertEqualObjects(session, dp1.data[@"session"]); | ||
// Check dp2 | ||
XCTAssertNotEqualObjects(session, dp2.session); | ||
XCTAssertNotEqualObjects(session, dp2.data[@"session"]); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// TestMemoryEventStore.m | ||
// Snowplow | ||
// | ||
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License | ||
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on | ||
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the Apache License Version 2.0 for the specific | ||
// language governing permissions and limitations there under. | ||
// | ||
// Authors: Jonathan Almeida | ||
// Copyright: Copyright (c) 2013-2021 Snowplow Analytics Ltd | ||
// License: Apache License Version 2.0 | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
#import "SPMemoryEventStore.h" | ||
#import "SPPayload.h" | ||
|
||
@interface TestMemoryEventStore : XCTestCase | ||
@end | ||
|
||
@implementation TestMemoryEventStore | ||
|
||
- (void)testInit { | ||
SPMemoryEventStore * eventStore = [[SPMemoryEventStore alloc] init]; | ||
XCTAssertNotNil(eventStore); | ||
} | ||
|
||
- (void)testInsertPayload { | ||
SPMemoryEventStore * eventStore = [[SPMemoryEventStore alloc] init]; | ||
[eventStore removeAllEvents]; | ||
|
||
// Build an event | ||
SPPayload * payload = [[SPPayload alloc] init]; | ||
[payload addValueToPayload:@"pv" forKey:@"e"]; | ||
[payload addValueToPayload:@"www.foobar.com" forKey:@"url"]; | ||
[payload addValueToPayload:@"Welcome to foobar!" forKey:@"page"]; | ||
[payload addValueToPayload:@"MEEEE" forKey:@"refr"]; | ||
|
||
// Insert an event | ||
[eventStore addEvent:payload]; | ||
|
||
XCTAssertEqual([eventStore count], 1); | ||
NSArray<SPEmitterEvent *> *events = [eventStore emittableEventsWithQueryLimit:1]; | ||
XCTAssertEqualObjects([events[0].payload getAsDictionary], [payload getAsDictionary]); | ||
[eventStore removeEventWithId:0]; | ||
|
||
XCTAssertEqual([eventStore count], 0); | ||
} | ||
|
||
- (void)testInsertManyPayloads { | ||
SPMemoryEventStore * eventStore = [[SPMemoryEventStore alloc] init]; | ||
[eventStore removeAllEvents]; | ||
|
||
// Build an event | ||
SPPayload * payload = [[SPPayload alloc] init]; | ||
[payload addValueToPayload:@"pv" forKey:@"e"]; | ||
[payload addValueToPayload:@"www.foobar.com" forKey:@"url"]; | ||
[payload addValueToPayload:@"Welcome to foobar!" forKey:@"page"]; | ||
[payload addValueToPayload:@"MEEEE" forKey:@"refr"]; | ||
|
||
for (int i = 0; i < 250; i++) { | ||
[eventStore addEvent:payload]; | ||
} | ||
|
||
XCTAssertEqual([eventStore count], 250); | ||
XCTAssertEqual([eventStore emittableEventsWithQueryLimit:600].count, 250); | ||
XCTAssertEqual([eventStore emittableEventsWithQueryLimit:150].count, 150); | ||
|
||
[eventStore removeAllEvents]; | ||
XCTAssertEqual([eventStore count], 0); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.