Skip to content

Commit

Permalink
Merge branch 'release/v3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Jimenez committed Feb 7, 2021
2 parents f21d3de + 2503e88 commit 272da16
Show file tree
Hide file tree
Showing 83 changed files with 673 additions and 1,894 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Cache
uses: actions/[email protected]
with:
path: Carthage
key: carthage
- uses: actions/checkout@v1
- name: Xcode Select
run: sudo xcode-select -s '/Applications/Xcode_11.3.app'
env:
DEVELOPER_DIR: '/Applications/Xcode_11.3.app/Contents/Developer'
- name: Setup Xcode version
uses: maxim-lobanov/[email protected]
with:
xcode-version: 11.4.1
- name: Carthage bootstrap
run: carthage bootstrap --cache-builds --platform iOS
- name: Build & Test
run: set -o pipefail && xcodebuild -project AppliverySDK.xcodeproj -scheme Applivery -sdk iphonesimulator -destination "platform=iOS Simulator,OS=$OS,name=$DEVICE" test | xcpretty
env:
OS: 13.3
DEVICE: "iPhone 11 Pro"
DEVELOPER_DIR: '/Applications/Xcode_11.3.app/Contents/Developer'

- name: Xcode Test
uses: sersoft-gmbh/[email protected]
with:
project: AppliverySDK.xcodeproj
scheme: Applivery
destination: "platform=iOS Simulator,OS=13.4.1,name=iPhone 11 Pro"
sdk: iphonesimulator
action: test
115 changes: 115 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/Applivery.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Applivery"
BuildableName = "Applivery"
BlueprintName = "Applivery"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Applivery_AppliveryBehaviorTests"
BuildableName = "Applivery_AppliveryBehaviorTests"
BlueprintName = "Applivery_AppliveryBehaviorTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Applivery_AppliveryTests"
BuildableName = "Applivery_AppliveryTests"
BlueprintName = "Applivery_AppliveryTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AppliveryTests"
BuildableName = "AppliveryTests"
BlueprintName = "AppliveryTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AppliveryBehaviorTests"
BuildableName = "AppliveryBehaviorTests"
BlueprintName = "AppliveryBehaviorTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Applivery"
BuildableName = "Applivery"
BlueprintName = "Applivery"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
osx_image: xcode11.3
osx_image: xcode11.4.1
language: objective-c
env:
global:
- FRAMEWORK_NAME=Applivery
- PROJECT=AppliverySDK
- SCHEME=Applivery
- OS=13.3
- OS=13.4.1
- DEVICE="iPhone 11 Pro"
cache:
directories:
Expand All @@ -16,7 +16,7 @@ before_script:
script:
- set -o pipefail && xcodebuild -project $PROJECT.xcodeproj -scheme $SCHEME -sdk iphonesimulator -destination "platform=iOS Simulator,OS=$OS,name=$DEVICE" test | xcpretty
before_deploy:
- carthage build --archive
- carthage build --archive --platform iOS
after_success:
- bash <(curl -s https://codecov.io/bash)
notifications:
Expand Down
6 changes: 3 additions & 3 deletions Applivery.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Pod::Spec.new do |s|
s.name = "Applivery"
s.version = "3.1.3"
s.version = "3.2"
s.summary = "Mobile App Distribution"
s.homepage = "https://www.applivery.com"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Alejandro Jiménez Agudo" => "[email protected]" }
s.social_media_url = "https://twitter.com/Applivery"
s.source = { :git => "https://github.com/applivery/applivery-ios-sdk.git", :tag => "v#{s.version}" }
s.platform = :ios, "9.0"
s.platform = :ios, "11.0"
s.source_files = "AppliverySDK/**/*.swift"
s.exclude_files = "AppliverySDK/**/getConstants.swift"
s.resource_bundle = { 'Applivery' => ["AppliverySDK/**/*.storyboard", "AppliverySDK/**/*.strings"] }
s.swift_version = "4.0"
s.swift_version = "5.0"
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import OHHTTPStubs
import OHHTTPStubsSwift
@testable import Applivery

class StubResponse {
Expand Down Expand Up @@ -40,11 +41,19 @@ class StubResponse {
}

class func stubResponse(with json: String) -> HTTPStubsResponse {
return HTTPStubsResponse(
fileAtPath: OHPathForFile(json, StubResponse.self)!,
statusCode: 200,
headers: ["Content-Type": "application/json"]
)
#if SWIFT_PACKAGE
return HTTPStubsResponse(
fileAtPath: OHPathForFileInBundle(json, Bundle.module)!,
statusCode: 200,
headers: ["Content-Type": "application/json"]
)
#else
return HTTPStubsResponse(
fileAtPath: OHPathForFile(json, StubResponse.self)!,
statusCode: 200,
headers: ["Content-Type": "application/json"]
)
#endif
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AppMock: AppProtocol {
// Outputs
var spyOpenUrl = (called: false, url: "")
var spyOtaAlert = (called: false, message: "")
var spyForceUpdateCalled = false
var spyAlertError = (called: false, message: "")
var spyWaitForReadyCalled = false
var spyPresentModal: (called: Bool, viewController: UIViewController?) = (false, nil)
Expand Down Expand Up @@ -72,6 +73,10 @@ class AppMock: AppProtocol {
self.spyOtaAlert = (true, message)
self.spyDownloadClosure = downloadHandler
}

func showForceUpdate() {
self.spyForceUpdateCalled = true
}

func showErrorAlert(_ message: String, retryHandler: @escaping () -> Void) {
self.spyAlertError = (true, message)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import UIKit
@testable import Applivery


Expand Down
7 changes: 7 additions & 0 deletions AppliveryBehaviorTests/Mocks/JSON/error_4002.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"status" : false,
"error" : {
"message" : "Invalid Token",
"code" : 4002
}
}
12 changes: 12 additions & 0 deletions AppliveryBehaviorTests/Mocks/JSON/error_5003.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"status" : false,
"error" : {
"message" : "Limit Exceeded",
"data" : {
"limit" : 3000,
"num" : 3000,
"itemName" : "downloadsByMonth.202006"
},
"code" : 5003
}
}
File renamed without changes.
14 changes: 10 additions & 4 deletions AppliveryBehaviorTests/Specs/FeedbackSpecs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017 Applivery S.L. All rights reserved.
//

import UIKit
import Quick
import Nimble
import OHHTTPStubs
Expand Down Expand Up @@ -417,15 +418,20 @@ class FeedbackSpecs: QuickSpec {
}

private func base64(image: UIImage) -> String? {
let imageData = UIImageJPEGRepresentation(image, 0.9)
let imageData = image.jpegData(compressionQuality: 0.9)
let base64String = imageData?.base64EncodedString()

return base64String
}

private func load(image: String) -> UIImage {
let bundle = Bundle.init(for: FeedbackSpecs.self)
let image = UIImage(named: image, in: bundle, compatibleWith: nil)
return image!
#if SWIFT_PACKAGE
let bundle = Bundle.module
#else
let bundle = Bundle.init(for: FeedbackSpecs.self)
#endif

let img = UIImage(named: image, in: bundle, compatibleWith: nil)
return img!
}
}
14 changes: 14 additions & 0 deletions AppliveryBehaviorTests/Specs/ForceUpdateSpecs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ class ForceUpdateSpecs: QuickSpec {
expect(self.updateViewMock.spyShowErrorMessage.message).toEventually(equal("Unexpected error"))
}
}
context("but service returns limit exceeded") {
beforeEach {
self.appMock.stubOpenUrlResult = true
StubResponse.mockResponse(for: "/v1/build/LAST_BUILD_ID_TEST/downloadToken", with: "error_5003.json")
self.updatePresenter.userDidTapDownload()
}
it("should hide loading") {
expect(self.updateViewMock.spyStopLoadingCalled).toEventually(beTrue())
}
it("should show error alert") {
expect(self.updateViewMock.spyShowErrorMessage.called).toEventually(beTrue())
expect(self.updateViewMock.spyShowErrorMessage.message).toEventually(equal(kLocaleErrorDownloadLimitMonth.replacingOccurrences(of: "%s", with: "3000")))
}
}
}
context("when download needs auth") {
var matchedDownloadURL = false
Expand Down
14 changes: 14 additions & 0 deletions AppliveryBehaviorTests/Specs/OTAUpdateSpecs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ class OTAUpdateSpecs: QuickSpec {
expect(self.appMock.spyHideLoadingCalled).toEventually(beTrue())
}
}
context("but service returns limit exceeded") {
beforeEach {
self.appMock.stubOpenUrlResult = true
StubResponse.mockResponse(for: "/v1/build/LAST_BUILD_ID_TEST/downloadToken", with: "error_5003.json")
self.appMock.spyDownloadClosure?()
}
it("should hide loading") {
expect(self.appMock.spyHideLoadingCalled).toEventually(beTrue())
}
it("should show error alert") {
expect(self.appMock.spyAlertError.called).toEventually(beTrue())
expect(self.appMock.spyAlertError.message).toEventually(equal(kLocaleErrorDownloadLimitMonth.replacingOccurrences(of: "%s", with: "3000")))
}
}
context("but service returns ko") {
beforeEach {
self.appMock.stubOpenUrlResult = true
Expand Down
4 changes: 4 additions & 0 deletions AppliveryBehaviorTests/Specs/RequestSpecs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class RequestSpecs: QuickSpec {
self.deviceMock?.fakeSystemName = "iOS"
self.deviceMock?.fakeModel = "iPhone 11 Pro"
self.deviceMock?.fakeType = "iPhone"
self.deviceMock?.fakeVendorId = "DEVICE_TEST_ID"

StubResponse.testRequest(url: "/test") { _, _, headersSent in
self.headersSent = headersSent
Expand All @@ -69,6 +70,9 @@ class RequestSpecs: QuickSpec {
it("should send the Bearer header") {
expect(self.headersSent?["Authorization"]).toEventually(equal("Bearer TEST_TOKEN"))
}
it("should send the device identifier header") {
expect(self.headersSent?["x-installation-token"]).toEventually(equal("DEVICE_TEST_ID"))
}
it("should send custom SDK headers") {
expect(self.headersSent?["x-sdk-version"]).toEventually(equal("IOS_3.0"))
expect(self.headersSent?["x-app-version"]).toEventually(equal("1.8"))
Expand Down
Loading

0 comments on commit 272da16

Please sign in to comment.