Skip to content

Commit

Permalink
Make ProvisioningProfile model equatable
Browse files Browse the repository at this point in the history
Also includes minor tweaks to tests in order to support a dictionary full of sample profiles and to check they all parse without failing.
  • Loading branch information
James Sherlock committed May 13, 2018
1 parent a76bdf8 commit b294709
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Foundation

/// Structure describing a Provisioning Profile and its contents
public struct ProvisioningProfile: Codable {
public struct ProvisioningProfile: Codable, Equatable {

enum CodingKeys: String, CodingKey {
case appIdName = "AppIDName"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,43 @@ class SwiftyProvisioningProfileTests: XCTestCase {
return Bundle(path: "\(currentBundle.bundlePath)/../../../../Tests/SwiftyProvisioningProfileTests/Resources")
}()

lazy var testProfileURL: URL = {
lazy var testProfileURL: [URL] = {
guard let bundle = resourceBundle else {
fatalError("Tests are being run through Xcode, or the project structure no longer matches up")
}

guard let url = bundle.url(forResource: "TestProfile", withExtension: "mobileprovision") else {
fatalError("No `TestProfile.mobileprovision` found in `Tests/SwiftyProvisioningProfileTests/Resources`")
guard let urls = bundle.urls(forResourcesWithExtension: "mobileprovision", subdirectory: nil) else {
fatalError("No `mobileprovision` files found in `Tests/SwiftyProvisioningProfileTests/Resources`")
}

return url
return urls
}()

func testParse() {
func testParseIOS() {

do {
let data = try Data(contentsOf: testProfileURL)
let profile = try ProvisioningProfile.parse(from: data)
for url in testProfileURL {
let data = try Data(contentsOf: url)
let profile = try ProvisioningProfile.parse(from: data)

print(profile)
}

print(profile)
// TODO: Create or find a simple & usable profile and wrtie actual tests for it
} catch {
XCTFail(String(describing: error))
}

}

func testParseMAC() {

// TODO

}

static var allTests = [
("testParse", testParse),
("testParseIOS", testParseIOS),
("testParseMAC", testParseMAC),
]
}

0 comments on commit b294709

Please sign in to comment.