Skip to content

Commit

Permalink
fix: internal type for model (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
MykolaVasyk authored Jun 25, 2024
1 parent 7536b39 commit 0833ab6
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sources/AppStoreConnectClient/Models/Build.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ public struct Build: Equatable {
/// The minimum version of the operating system required to run this build.
public let minOsVersion: String?

/// Initializes a `Build` instance with the provided parameters.
/// - Parameters:
/// - id: A unique identifier for the build.
/// - version: The version number of the build.
/// - uploadedDate: The date when the build was uploaded, if available.
/// - minOsVersion: The minimum OS version required for this build, if specified.
/// - Note: Some properties may be nil if not provided during initialization.
public init(id: String, version: String, uploadedDate: Date?, minOsVersion: String?) {
self.id = id
self.version = version
self.uploadedDate = uploadedDate
self.minOsVersion = minOsVersion
}

/// Initializes a `Build` instance with the provided App Store Connect build schema.
/// - Parameters:
/// - schema: The schema representing the build from the API.
Expand Down
12 changes: 12 additions & 0 deletions Sources/AppStoreConnectClient/Models/PreReleaseVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ public struct PreReleaseVersion {
/// The platform for which the pre-release version is intended.
public let platform: String?

/// Initializes a `PreReleaseVersion` instance with the provided parameters.
/// - Parameters:
/// - id: The unique identifier for the pre-release version.
/// - version: The version string of the pre-release version.
/// - platform: The platform for which the pre-release version is intended, if specified.
/// - Note: This initializer creates a new `PreReleaseVersion` instance with the given information.
public init(id: String, version: String, platform: String?) {
self.id = id
self.version = version
self.platform = platform
}

/// Initializes a `PreReleaseVersion` instance with the provided testFlight's pre-release version schema.
/// - Parameters:
/// - schema: The schema representing the pre-release version from the API.
Expand Down
9 changes: 9 additions & 0 deletions Sources/AppStoreConnectClient/Models/Release.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public struct Release {
/// The state of the release on the App Store.
public let appStoreState: String

/// Initializes a `Release` instance with the provided parameters.
/// - Parameters:
/// - version: The version string of the release.
/// - appStoreState: The state of the release on the App Store.
/// - Note: This initializer creates a new `Release` instance with the given information.
public init(version: String, appStoreState: String) {
self.version = version
self.appStoreState = appStoreState
}
/// Initializes a `Release` instance with the provided App Store version schema.
/// - Parameters:
/// - schema: The schema representing the App Store version.
Expand Down
12 changes: 12 additions & 0 deletions Tests/AppStoreConnectClientTests/BuildTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ final class BuildTest: XCTestCase {
XCTAssertNil(build.uploadedDate)
XCTAssertNil(build.minOsVersion)
}

func testBuildInitializer() {
let id = "mock-123"
let version = "mock-1.0.0"
let uploadedDate = Date()
let minOsVersion = "mock-14.0"
let build = Build(id: id, version: version, uploadedDate: uploadedDate, minOsVersion: minOsVersion)
XCTAssertEqual(build.id, id)
XCTAssertEqual(build.version, version)
XCTAssertEqual(build.uploadedDate, uploadedDate)
XCTAssertEqual(build.minOsVersion, minOsVersion)
}
}
10 changes: 10 additions & 0 deletions Tests/AppStoreConnectClientTests/PreReleaseVersionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ final class PreReleaseVersionTest: XCTestCase {
XCTAssertNil(preReleaseVersion.version)
XCTAssertNil(preReleaseVersion.platform)
}

func testPreReleaseVersionInitializer() {
let id = "mock-456"
let version = "mock-2.0.0"
let platform = "mock-iOS"
let preRelease = PreReleaseVersion(id: id, version: version, platform: platform)
XCTAssertEqual(preRelease.id, id)
XCTAssertEqual(preRelease.version, version)
XCTAssertEqual(preRelease.platform, platform)
}
}
8 changes: 8 additions & 0 deletions Tests/AppStoreConnectClientTests/ReleaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ final class ReleaseTests: XCTestCase {
let release = Release(schema: schema)
XCTAssertNil(release)
}

func testReleaseInitializer() {
let version = "mock-3.0.0"
let appStoreState = "mock-Ready for Sale"
let release = Release(version: version, appStoreState: appStoreState)
XCTAssertEqual(release.version, version)
XCTAssertEqual(release.appStoreState, appStoreState)
}
}

0 comments on commit 0833ab6

Please sign in to comment.