Skip to content

Commit

Permalink
fix: added alias for Region (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 committed Apr 15, 2024
2 parents f601bca + 33861db commit 1619c72
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
1 change: 1 addition & 0 deletions Sources/DataPipeline/Type/Aliases.swift
Expand Up @@ -31,3 +31,4 @@ public typealias OperatingMode = Segment.OperatingMode
public typealias Metric = CioInternalCommon.Metric
public typealias CustomerIO = CioInternalCommon.CustomerIO
public typealias CioLogLevel = CioInternalCommon.CioLogLevel
public typealias Region = CioInternalCommon.Region
39 changes: 39 additions & 0 deletions Tests/Common/APITest.swift
Expand Up @@ -13,6 +13,12 @@ import XCTest
class CommonAPITest: UnitTest {
// Test that public functions are accessible by mocked instances
let mock = CustomerIOInstanceMock()
let dictionaryData: [String: Any] = ["foo": true, "bar": ""]
struct CodableExample: Codable {
let foo: String
}

let codedData = CodableExample(foo: "")

func test_allPublicStaticPropertiesAvailable() throws {
try skipRunningTest()
Expand All @@ -28,6 +34,39 @@ class CommonAPITest: UnitTest {
// Reference some objects that should be public in the Tracking module
let _: Region = .EU
let _: CioLogLevel = .debug

mock.identify(userId: "", traits: nil)
mock.identify(userId: "", traits: dictionaryData)
mock.identify(userId: "", traits: codedData)

// clear identify
mock.clearIdentify()

// event tracking
mock.track(name: "", properties: nil)
mock.track(name: "", properties: dictionaryData)
mock.track(name: "", properties: codedData)

// screen tracking
mock.screen(title: "", properties: nil)
mock.screen(title: "", properties: dictionaryData)
mock.screen(title: "", properties: codedData)

// register push token
mock.registerDeviceToken("")

// delete push token
mock.deleteDeviceToken()

// track push metric
let metric = Metric.delivered
mock.trackMetric(deliveryID: "", event: metric, deviceToken: "")

// profile attributes
mock.profileAttributes = dictionaryData

// device attributes
mock.deviceAttributes = dictionaryData
}

// This function checks that SdkConfig is accessible and can be created using the factory.
Expand Down
20 changes: 1 addition & 19 deletions Tests/DataPipeline/APITest.swift
@@ -1,5 +1,4 @@
import CioDataPipelines // do not use `@testable` so we can test functions are made public and not `internal`.
import CioInternalCommon
import Foundation
import Segment
import SharedTests
Expand All @@ -21,9 +20,6 @@ class DataPipelineAPITest: UnitTest {
let codedData = CodableExample(foo: "")
let exampleURL = URL(string: "https://example.com")!

// Test that public functions are accessible by mocked instances
let mock = CustomerIOInstanceMock()

// This function checks that public functions exist for the SDK and they are callable.
// Maybe we forgot to add a function? Maybe we forgot to make a function `public`?
func test_allPublicFunctions() throws {
Expand All @@ -34,52 +30,37 @@ class DataPipelineAPITest: UnitTest {

// Identify
CustomerIO.shared.identify(userId: "")
mock.identify(userId: "", traits: nil)
CustomerIO.shared.identify(userId: "", traits: dictionaryData)
mock.identify(userId: "", traits: dictionaryData)
CustomerIO.shared.identify(userId: "", traits: codedData)
mock.identify(userId: "", traits: codedData)

// clear identify
CustomerIO.shared.clearIdentify()
mock.clearIdentify()

// event tracking
CustomerIO.shared.track(name: "")
mock.track(name: "", properties: nil)
CustomerIO.shared.track(name: "", properties: dictionaryData)
mock.track(name: "", properties: dictionaryData)
CustomerIO.shared.track(name: "", properties: codedData)
mock.track(name: "", properties: codedData)

// screen tracking
CustomerIO.shared.screen(title: "")
mock.screen(title: "", properties: nil)
CustomerIO.shared.screen(title: "", properties: dictionaryData)
mock.screen(title: "", properties: dictionaryData)
CustomerIO.shared.screen(title: "", properties: codedData)
mock.screen(title: "", properties: codedData)

// register push token
CustomerIO.shared.registerDeviceToken("")
mock.registerDeviceToken("")

// delete push token
CustomerIO.shared.deleteDeviceToken()
mock.deleteDeviceToken()

// track push metric
let metric = Metric.delivered
CustomerIO.shared.trackMetric(deliveryID: "", event: metric, deviceToken: "")
mock.trackMetric(deliveryID: "", event: metric, deviceToken: "")

// profile attributes
CustomerIO.shared.profileAttributes = dictionaryData
mock.profileAttributes = dictionaryData

// device attributes
CustomerIO.shared.deviceAttributes = dictionaryData
mock.deviceAttributes = dictionaryData

// plugins
CustomerIO.shared.apply { (_: Plugin) in }
Expand Down Expand Up @@ -110,6 +91,7 @@ class DataPipelineAPITest: UnitTest {
try skipRunningTest()

_ = SDKConfigBuilder(cdpApiKey: .random)
.region(Region.US)
.logLevel(.info)
.apiHost("")
.cdnHost("")
Expand Down

0 comments on commit 1619c72

Please sign in to comment.