Skip to content

Commit

Permalink
Refactor project + remove example + fix tests + add SonarCloud config…
Browse files Browse the repository at this point in the history
…uration
  • Loading branch information
gouyelliot committed Mar 25, 2020
1 parent ccc11dd commit 54e7c75
Show file tree
Hide file tree
Showing 35 changed files with 351 additions and 1,144 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: iOS CI

on: [push]

jobs:
build:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Run CI
run: make ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ DerivedData
Carthage
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Note: if you ignore the Pods directory, make sure to uncomment
# `pod install` in .travis.yml
#
Example/Pods
Example/Pods/
.scannerwork/
Binary file added .sonar/build-wrapper-macosx-x86
Binary file not shown.
Binary file added .sonar/libinterceptor.dylib
Binary file not shown.
Binary file added .sonar/sonar-scanner-cli-4.2.0.1873.jar
Binary file not shown.
31 changes: 31 additions & 0 deletions .sonar/xccov-to-sonarqube-generic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail

function convert_file {
local xccovarchive_file="$1"
local file_name="$2"
local xccov_options="$3"
echo " <file path=\"$file_name\">"
xcrun xccov view $xccov_options --file "$file_name" "$xccovarchive_file" | \
sed -n '
s/^ *\([0-9][0-9]*\): 0.*$/ <lineToCover lineNumber="\1" covered="false"\/>/p;
s/^ *\([0-9][0-9]*\): [1-9].*$/ <lineToCover lineNumber="\1" covered="true"\/>/p
'
echo ' </file>'
}

function xccov_to_generic {
echo '<coverage version="1">'
for xccovarchive_file in "$@"; do
local xccov_options=""
if [[ $xccovarchive_file == *".xcresult"* ]]; then
xccov_options="--archive"
fi
xcrun xccov view $xccov_options --file-list "$xccovarchive_file" | while read -r file_name; do
convert_file "$xccovarchive_file" "$file_name" "$xccov_options"
done
done
echo '</coverage>'
}

xccov_to_generic "$@"
228 changes: 227 additions & 1 deletion BatchFirebaseDispatcher.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>
#import <OCMock.h>
#import <OCMock/OCMock.h>
#import <FirebaseAnalytics/FirebaseAnalytics.h>

#import "BatchFirebaseDispatcher.h"
Expand Down Expand Up @@ -44,7 +44,7 @@ - (void)testPushNoData
{
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen payload:testPayload];

NSString *expectedName = @"batch_notification_open";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -59,7 +59,7 @@ - (void)testNotificationDeeplinkQueryVars
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com?utm_source=batchsdk&utm_medium=push-batch&utm_campaign=yoloswag&utm_content=button1";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen payload:testPayload];

NSString *expectedName = @"batch_notification_open";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -76,7 +76,7 @@ - (void)testNotificationDeeplinkQueryVarsEncode
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com?utm_source=%5Bbatchsdk%5D&utm_medium=push-batch&utm_campaign=yoloswag&utm_content=button1";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen payload:testPayload];

NSString *expectedName = @"batch_notification_open";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -93,7 +93,7 @@ - (void)testNotificationDeeplinkFragmentVars
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com#utm_source=batch-sdk&utm_medium=pushbatch01&utm_campaign=154879548754&utm_content=notif001";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen payload:testPayload];

NSString *expectedName = @"batch_notification_open";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -110,7 +110,7 @@ - (void)testNotificationDeeplinkNonTrimmed
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @" \n https://batch.com#utm_source=batch-sdk&utm_medium=pushbatch01&utm_campaign=154879548754&utm_content=notif001 \n ";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen payload:testPayload];

NSString *expectedName = @"batch_notification_open";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -127,7 +127,7 @@ - (void)testNotificationDeeplinkFragmentVarsEncode
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com/test#utm_source=%5Bbatch-sdk%5D&utm_medium=pushbatch01&utm_campaign=154879548754&utm_content=notif001";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen payload:testPayload];

NSString *expectedName = @"batch_notification_open";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -150,7 +150,7 @@ - (void)testNotificationCustomPayload
@"utm_content": @"allo118218",
};

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen payload:testPayload];

NSString *expectedName = @"batch_notification_open";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -170,7 +170,7 @@ - (void)testNotificationDeeplinkPriority
@"utm_medium": @"654987",
};

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeNotificationOpen payload:testPayload];

NSString *expectedName = @"batch_notification_open";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -186,7 +186,7 @@ - (void)testInAppNoData
{
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeInAppShow andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeMessagingShow payload:testPayload];

NSString *expectedName = @"batch_in_app_show";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -201,7 +201,7 @@ - (void)testInAppTrackingID
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.trackingId = @"jesuisuntrackingid";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeInAppShow andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeMessagingShow payload:testPayload];

NSString *expectedName = @"batch_in_app_show";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -218,7 +218,7 @@ - (void)testInAppDeeplinkContentQueryVars
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com/test-ios?utm_content=yoloswag";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeInAppClick andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeMessagingClick payload:testPayload];

NSString *expectedName = @"batch_in_app_click";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -234,7 +234,7 @@ - (void)testInAppDeeplinkContentQueryVarsUppercase
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com/test-ios?UtM_coNTEnt=yoloswag";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeInAppClick andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeMessagingClick payload:testPayload];

NSString *expectedName = @"batch_in_app_click";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -251,7 +251,7 @@ - (void)testInAppDeeplinkFragmentQueryVars
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com/test-ios#utm_content=yoloswag2";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeInAppClick andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeMessagingClick payload:testPayload];

NSString *expectedName = @"batch_in_app_click";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -267,7 +267,7 @@ - (void)testInAppDeeplinkFragmentQueryVarsUppercase
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com/test-ios#uTm_CoNtEnT=yoloswag2";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeInAppClick andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeMessagingClick payload:testPayload];

NSString *expectedName = @"batch_in_app_click";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -283,7 +283,7 @@ - (void)testInAppDeeplinkContentPriority
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com/test-ios?utm_content=testprio#utm_content=yoloswag2";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeInAppClose andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeMessagingClose payload:testPayload];

NSString *expectedName = @"batch_in_app_close";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand All @@ -299,7 +299,7 @@ - (void)testInAppDeeplinkContentNoId
BatchPayloadDispatcherTest *testPayload = [[BatchPayloadDispatcherTest alloc] init];
testPayload.deeplink = @"https://batch.com?utm_content=jesuisuncontent";

[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeInAppClose andPayload:testPayload];
[self.dispatcher dispatchEventWithType:BatchEventDispatcherTypeMessagingClose payload:testPayload];

NSString *expectedName = @"batch_in_app_close";
NSDictionary<NSString *, id> *expectedParameters = @{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

@implementation BatchPayloadDispatcherTest

@synthesize notificationUserInfo;
@synthesize sourceMessage;

- (nullable NSObject *)customValueForKey:(nonnull NSString *)key {
if (self.customPayload != nil) {
return [self.customPayload objectForKey:key];
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
github "BatchLabs/ios-sdk" >= 1.15.0
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
github "erikdoe/ocmock" >= 3.6
3 changes: 2 additions & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" "6.18.0"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" "6.19.0"
github "BatchLabs/ios-sdk" "1.15.0"
github "erikdoe/ocmock" "v3.6"
Loading

0 comments on commit 54e7c75

Please sign in to comment.