Skip to content

Commit

Permalink
Merge branch 'feature/unit_tests' into 'develop'
Browse files Browse the repository at this point in the history
ADAPTY-2570 Models serialisation tests
  • Loading branch information
Skifcha committed Nov 19, 2021
2 parents 77475d8 + 1ebfaab commit 30b9876
Show file tree
Hide file tree
Showing 15 changed files with 738 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Adapty/Classes/ApiManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public typealias ProfileCreateCompletion = (PurchaserInfoModel?, AdaptyError?, Bool?) -> Void
public typealias InstallationCompletion = (InstallationModel?, AdaptyError?) -> Void
typealias InstallationCompletion = (InstallationModel?, AdaptyError?) -> Void
public typealias PaywallsCompletion = ([PaywallModel]?, [ProductModel]?, AdaptyError?) -> Void
public typealias ValidateReceiptCompletion = (PurchaserInfoModel?, Parameters?, AdaptyError?) -> Void
public typealias JSONCompletion = (Parameters?, AdaptyError?) -> Void
Expand Down
5 changes: 4 additions & 1 deletion Adapty/Classes/DefaultsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import Foundation
class DefaultsManager {

static let shared = DefaultsManager()
private let defaults = UserDefaults.standard
private var defaults = UserDefaults.standard

private init() {}
init(with defaults: UserDefaults) {
self.defaults = defaults
}

var profileId: String {
get {
Expand Down
11 changes: 10 additions & 1 deletion Adapty/Classes/InstallationModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public class InstallationModel: JSONCodable, Codable {
class InstallationModel: JSONCodable, Codable {

var profileInstallationMetaId: String
var iamAccessKeyId: String
Expand Down Expand Up @@ -44,5 +44,14 @@ public class InstallationModel: JSONCodable, Codable {
if self.iamSessionToken.isEmpty { missingParams.append("iam_session_token") }
if !missingParams.isEmpty { LoggerManager.logError(AdaptyError.missingParam("InstallationModel - \(missingParams.joined(separator: ", "))")) }
}
}

extension InstallationModel: Equatable { }

func == (lhs: InstallationModel, rhs: InstallationModel) -> Bool {
if lhs.profileInstallationMetaId == rhs.profileInstallationMetaId, lhs.iamAccessKeyId == rhs.iamAccessKeyId, lhs.iamSecretKey == rhs.iamSecretKey, lhs.iamSessionToken == rhs.iamSessionToken {
return true
}

return false
}
67 changes: 63 additions & 4 deletions Example/Adapty.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@
objects = {

/* Begin PBXBuildFile section */
4A9C8BFE274695DA00392217 /* PurchaserInfo.json in Resources */ = {isa = PBXBuildFile; fileRef = 4A9C8BFC274694DB00392217 /* PurchaserInfo.json */; };
4A9C8C00274697CA00392217 /* Paywall.json in Resources */ = {isa = PBXBuildFile; fileRef = 4A9C8BFF274697CA00392217 /* Paywall.json */; };
4A9C8C0427469A5A00392217 /* Product.json in Resources */ = {isa = PBXBuildFile; fileRef = 4A9C8C0327469A5A00392217 /* Product.json */; };
4A9C8C062747B78100392217 /* PaywallArray.json in Resources */ = {isa = PBXBuildFile; fileRef = 4A9C8C052747B78100392217 /* PaywallArray.json */; };
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
75E09E001FF56A10F9975314 /* Pods_Adapty_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6933B2657041857BD974C893 /* Pods_Adapty_Tests.framework */; };
9A0AF094E860226F6230BAA9 /* Pods_Adapty_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BAE9CF399A8493F9C5027242 /* Pods_Adapty_Example.framework */; };
D613205023A385A900402998 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D613204F23A385A900402998 /* StoreKit.framework */; };
D65757C5248FE2740055A431 /* InAppContainersTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D65757C4248FE2730055A431 /* InAppContainersTableViewCell.swift */; };
D664B0B42571100C00962C23 /* UserDefaultsMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = D664B0B32571100C00962C23 /* UserDefaultsMock.swift */; };
D664B0B6257110A000962C23 /* DefaultsManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D664B0B5257110A000962C23 /* DefaultsManagerTests.swift */; };
D67A1911257E33A700A680B0 /* ModelsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D67A1910257E33A700A680B0 /* ModelsTests.swift */; };
D6F8D53223B0E1CE00CB719A /* InAppTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F8D53123B0E1CE00CB719A /* InAppTableViewCell.swift */; };
D6F8D53423B0E22300CB719A /* InAppTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F8D53323B0E22300CB719A /* InAppTableViewController.swift */; };
D6F8D53C23BFBC8100CB719A /* InAppContainersTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F8D53B23BFBC8100CB719A /* InAppContainersTableViewController.swift */; };
Expand All @@ -35,6 +41,10 @@

/* Begin PBXFileReference section */
0B77B02FCC407C887AADA018 /* Pods-Adapty_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Adapty_Tests.release.xcconfig"; path = "Target Support Files/Pods-Adapty_Tests/Pods-Adapty_Tests.release.xcconfig"; sourceTree = "<group>"; };
4A9C8BFC274694DB00392217 /* PurchaserInfo.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = PurchaserInfo.json; sourceTree = "<group>"; };
4A9C8BFF274697CA00392217 /* Paywall.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Paywall.json; sourceTree = "<group>"; };
4A9C8C0327469A5A00392217 /* Product.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Product.json; sourceTree = "<group>"; };
4A9C8C052747B78100392217 /* PaywallArray.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = PaywallArray.json; sourceTree = "<group>"; };
4AE005B626BC7B3800FE4D12 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../Package.swift; sourceTree = "<group>"; };
53AD3D6D363A126F96F974FE /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
588DF37E8E29D1227EDF23E6 /* Pods-Adapty_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Adapty_Example.release.xcconfig"; path = "Target Support Files/Pods-Adapty_Example/Pods-Adapty_Example.release.xcconfig"; sourceTree = "<group>"; };
Expand All @@ -47,14 +57,16 @@
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
607FACE51AFB9204008FA782 /* Adapty_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Adapty_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
6933B2657041857BD974C893 /* Pods_Adapty_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Adapty_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
72E1331FC8AE46397495452B /* Pods-Adapty_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Adapty_Tests.debug.xcconfig"; path = "Target Support Files/Pods-Adapty_Tests/Pods-Adapty_Tests.debug.xcconfig"; sourceTree = "<group>"; };
8049AD70F15878396F72026E /* Pods-Adapty_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Adapty_Example.debug.xcconfig"; path = "Target Support Files/Pods-Adapty_Example/Pods-Adapty_Example.debug.xcconfig"; sourceTree = "<group>"; };
B3A0F805975930A3344E36CB /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
BAE9CF399A8493F9C5027242 /* Pods_Adapty_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Adapty_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D613204F23A385A900402998 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
D65757C4248FE2730055A431 /* InAppContainersTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppContainersTableViewCell.swift; sourceTree = "<group>"; };
D664B0B32571100C00962C23 /* UserDefaultsMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsMock.swift; sourceTree = "<group>"; };
D664B0B5257110A000962C23 /* DefaultsManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultsManagerTests.swift; sourceTree = "<group>"; };
D67A1910257E33A700A680B0 /* ModelsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelsTests.swift; sourceTree = "<group>"; };
D6F8D53123B0E1CE00CB719A /* InAppTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppTableViewCell.swift; sourceTree = "<group>"; };
D6F8D53323B0E22300CB719A /* InAppTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppTableViewController.swift; sourceTree = "<group>"; };
D6F8D53B23BFBC8100CB719A /* InAppContainersTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppContainersTableViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -83,6 +95,17 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
4A9C8BFB2746944900392217 /* Models JSON */ = {
isa = PBXGroup;
children = (
4A9C8BFC274694DB00392217 /* PurchaserInfo.json */,
4A9C8BFF274697CA00392217 /* Paywall.json */,
4A9C8C0327469A5A00392217 /* Product.json */,
4A9C8C052747B78100392217 /* PaywallArray.json */,
);
path = "Models JSON";
sourceTree = "<group>";
};
607FACC71AFB9204008FA782 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -134,7 +157,10 @@
607FACE81AFB9204008FA782 /* Tests */ = {
isa = PBXGroup;
children = (
607FACEB1AFB9204008FA782 /* Tests.swift */,
4A9C8BFB2746944900392217 /* Models JSON */,
D664B0B225710FBA00962C23 /* Mocks */,
D664B0B5257110A000962C23 /* DefaultsManagerTests.swift */,
D67A1910257E33A700A680B0 /* ModelsTests.swift */,
607FACE91AFB9204008FA782 /* Supporting Files */,
);
path = Tests;
Expand All @@ -159,6 +185,14 @@
name = "Podspec Metadata";
sourceTree = "<group>";
};
D664B0B225710FBA00962C23 /* Mocks */ = {
isa = PBXGroup;
children = (
D664B0B32571100C00962C23 /* UserDefaultsMock.swift */,
);
path = Mocks;
sourceTree = "<group>";
};
D6793E0502AA6C43737D614F /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -210,6 +244,7 @@
607FACE11AFB9204008FA782 /* Sources */,
607FACE21AFB9204008FA782 /* Frameworks */,
607FACE31AFB9204008FA782 /* Resources */,
78CD3C53374DCE5B9A7975E3 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -277,6 +312,10 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4A9C8C0427469A5A00392217 /* Product.json in Resources */,
4A9C8C062747B78100392217 /* PaywallArray.json in Resources */,
4A9C8C00274697CA00392217 /* Paywall.json in Resources */,
4A9C8BFE274695DA00392217 /* PurchaserInfo.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -327,6 +366,24 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
78CD3C53374DCE5B9A7975E3 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Adapty_Tests/Pods-Adapty_Tests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Adapty_Tests/Pods-Adapty_Tests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
D3ADBA4FD48E29241F03C0F5 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -370,7 +427,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
D664B0B42571100C00962C23 /* UserDefaultsMock.swift in Sources */,
D67A1911257E33A700A680B0 /* ModelsTests.swift in Sources */,
D664B0B6257110A000962C23 /* DefaultsManagerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -50,6 +52,15 @@
ReferencedContainer = "container:Adapty.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5CC9A652521B99CD61797A6A165DC46D"
BuildableName = "Adapty.framework"
BlueprintName = "Adapty"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
Expand Down
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ target 'Adapty_Example' do
target 'Adapty_Tests' do
inherit! :search_paths


pod 'Nimble'
end
end

Expand Down
10 changes: 7 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
PODS:
- Adapty (1.16.3)
- Adapty (1.16.4)
- Adjust (4.29.6):
- Adjust/Core (= 4.29.6)
- Adjust/Core (4.29.6)
- AppsFlyerFramework (6.0.8)
- Branch (0.33.1):
- Branch/Core (= 0.33.1)
- Branch/Core (0.33.1)
- Nimble (9.2.1)

DEPENDENCIES:
- Adapty (from `../`)
- Adjust (~> 4.29.6)
- AppsFlyerFramework (~> 6.0.5)
- Branch (~> 0.33.1)
- Nimble

SPEC REPOS:
trunk:
- Adjust
- AppsFlyerFramework
- Branch
- Nimble

EXTERNAL SOURCES:
Adapty:
:path: "../"

SPEC CHECKSUMS:
Adapty: a7b0104b17ca45ff9ee86bbb0eb3c0702bb93e3a
Adapty: 9dd0fc441032ccdd7f2800ee861ba7ff79a4e751
Adjust: 94f1c99429fb2a7ebe530294fd66a88d63a54922
AppsFlyerFramework: 57fb1fc68a5b8103353ce94d6e57861cbc4a55c3
Branch: 65d05ffb137ef504777cff6bd4fb6f770f17145a
Nimble: e7e615c0335ee4bf5b0d786685451e62746117d5

PODFILE CHECKSUM: 22b96e75a823022d65d79b5eb0517a1cffbc589d
PODFILE CHECKSUM: d72c1fc10f9aaa6daf274125cc8ef02a87a146d4

COCOAPODS: 1.10.1
Loading

0 comments on commit 30b9876

Please sign in to comment.