Skip to content

Commit

Permalink
resolve review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode committed Jun 6, 2024
1 parent 7e45c94 commit 9c31f85
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ actor EndpointClient: EndpointClientBehaviour {
}

let endpointInformation = await endpointInformationProvider.endpointInfo()

endpointProfile.endpointId = configuration.uniqueDeviceId
endpointProfile.deviceToken = deviceToken
endpointProfile.location = .init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ protocol EndpointInformationProvider {
struct DefaultEndpointInformationProvider: EndpointInformationProvider {
func endpointInfo() async -> EndpointInformation {
let deviceInfo = await DeviceInfo.current
let model = await DeviceInfo.current.model
let platform = await DeviceInfo.current.operatingSystem
let model = await deviceInfo.model
let platform = await deviceInfo.operatingSystem
let appVersion = Bundle.main.appVersion
return EndpointInformation(model: model, appVersion: appVersion, platform: platform)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

@_spi(InternalAWSPinpoint) @testable import InternalAWSPinpoint
import XCTest

class EndpointInformationProviderTests: XCTestCase {

/// Given: DefaultEndpointInformationProvider
/// When: endpointInfo() is called
/// Then: endpoint information is returned not nil
func testGetEndpointInformation() async {
let provider = DefaultEndpointInformationProvider()
let endpointInfo = await provider.endpointInfo()
XCTAssertNotNil(endpointInfo)
}

/// Given: DefaultEndpointInformationProvider
/// When: endpointInfo() is called
/// Then: endpoint information returned contains platform name/version, app version, model,
func testGetEndpointInformationDetails() async {
let provider = DefaultEndpointInformationProvider()
let endpointInfo = await provider.endpointInfo()
let platformName = endpointInfo.platform.name
let platformVersion = endpointInfo.platform.version
let model = endpointInfo.model
let version = endpointInfo.appVersion

XCTAssertNotNil(platformName)
XCTAssertNotNil(platformVersion)
XCTAssertNotNil(model)
XCTAssertNotNil(version)

#if os(macOS)
XCTAssertEqual(platformName, "macOS")
#elseif os(iOS)
XCTAssertEqual(platformName, "iOS")
XCTAssertEqual(model, "iPhone")
#elseif os(tvOS)
XCTAssertEqual(platformName, "tvOS")
XCTAssertEqual(model, "Apple TV")
#elseif os(watchOS)
XCTAssertEqual(platformName, "watchOS")
XCTAssertEqual(model, "Apple Watch")
#endif
}
}

0 comments on commit 9c31f85

Please sign in to comment.