From 6c971fb882b6b0cc33e83f14cd9f5bf4f31c91b2 Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Sun, 30 Jun 2024 23:43:08 +0300 Subject: [PATCH 01/11] [ZEUS-4454] Updated tests --- Package.swift | 7 ++- ...ft.swift => PlayBackSDKManagerTests.swift} | 48 +++++++++++++++++++ Tests/PlaybackSDKTests/TestConfig.swift | 4 +- 3 files changed, 56 insertions(+), 3 deletions(-) rename Tests/PlaybackSDKTests/{PlayBackSDKManagerTests.swift.swift => PlayBackSDKManagerTests.swift} (66%) diff --git a/Package.swift b/Package.swift index 74145a4..edb1cc2 100644 --- a/Package.swift +++ b/Package.swift @@ -43,6 +43,11 @@ let package = Package( ), .testTarget( name: "PlaybackSDKTests", - dependencies: ["PlaybackSDK"]), + dependencies: ["PlaybackSDK"], + exclude: ["Folder Structure.md"], // Exclude non-Swift test files if needed + swiftSettings: [ + // Set the swift settings specifically for iOS platform + .define("iOS_TEST", .when(platforms: [.iOS])), + ]), ] ) diff --git a/Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift.swift b/Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift similarity index 66% rename from Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift.swift rename to Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift index 9652f90..f73efce 100644 --- a/Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift.swift +++ b/Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift @@ -34,6 +34,23 @@ class PlayBackSDKManagerTests: XCTestCase { func testInitialization() throws { XCTAssertNotNil(manager, "Manager should not be nil after initialization") } + + func testInitializeWithCustomUserAgent() { + let expectation = expectation(description: "Initialization expectation") + + manager.initialize(apiKey: apiKey, userAgent: "IOS Tests") { result in + switch result { + case .success(let license): + XCTAssertNotNil(license, "Bitmovin license should not be nil") + XCTAssertFalse(license.isEmpty, "Bitmovin license should not be empty") + expectation.fulfill() + case .failure(let error): + XCTFail("Initialization failed with error: \(error.localizedDescription)") + } + } + + waitForExpectations(timeout: 5, handler: nil) + } func testInitializeWithValidAPIKey() { let expectation = expectation(description: "Initialization expectation") @@ -94,6 +111,37 @@ class PlayBackSDKManagerTests: XCTestCase { waitForExpectations(timeout: 5, handler: nil) } + func testFailedEntryId() { + let initializationExpectation = expectation(description: "SDK initialization") + manager.initialize(apiKey: apiKey) { result in + switch result { + case .success: + initializationExpectation.fulfill() + case .failure(let error): + XCTFail("SDK initialization failed with error: \(error.localizedDescription)") + } + } + waitForExpectations(timeout: 5, handler: nil) + + let hlsExpectation = expectation(description: "Empty entry id loading expectation") + manager.loadHLSStream(forEntryId: "", andAuthorizationToken: nil) { result in + switch result { + case .success(let hlsURL): + XCTFail("Empty entry id provided but got HLS stream") + case .failure(let error): + switch error { + case .networkError(_): + hlsExpectation.fulfill() + default: + hlsExpectation.fulfill() + } + + } + } + + waitForExpectations(timeout: 5, handler: nil) + } + func testLoadPlayer() { let playerView = manager.loadPlayer(entryID: "exampleEntryID", authorizationToken: "exampleToken", onError: { _ in }) // Assert that playerView is not nil or do further UI testing if possible diff --git a/Tests/PlaybackSDKTests/TestConfig.swift b/Tests/PlaybackSDKTests/TestConfig.swift index f956a42..7d5e217 100644 --- a/Tests/PlaybackSDKTests/TestConfig.swift +++ b/Tests/PlaybackSDKTests/TestConfig.swift @@ -8,6 +8,6 @@ import Foundation internal struct TestConfig { - static let testAPIKey = "f3Beljhmlz2ea7M9TfErE6mKPsAcY3BrasMMEG24" - static let testEntryID = "0_k3mz0mf8" + static let testAPIKey = "EJEZPIezBkaf0EQ7ey5Iu2MDA2ARUkgc79eyDOnG" + static let testEntryID = "0_qt9cy11s" } From a6dd36bf26199a32e812648becbff60590f43fb7 Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Sun, 30 Jun 2024 23:47:44 +0300 Subject: [PATCH 02/11] [ZEUS-4454] Updated swift.yml to run tests when merged PR --- .github/workflows/swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 3b1954b..b2d5cf3 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -5,9 +5,9 @@ name: SPM Build and Test on: push: - branches: [ "feature/unit-test" ] + branches: [ "feature/unit-test", "main", "release/1.0.3", "release/1.0.4"] pull_request: - branches: [ "feature/unit-test" ] + branches: [ "feature/unit-test", "main", "release/1.0.3", "release/1.0.4" ] jobs: build: From dad173b02e8f10d2313f40398a21ffd47d7ac77c Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Sun, 30 Jun 2024 23:49:34 +0300 Subject: [PATCH 03/11] [ZEUS-4454] Removed release/1.0.4 branch from swift.yml --- .github/workflows/swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index b2d5cf3..981ded6 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -5,9 +5,9 @@ name: SPM Build and Test on: push: - branches: [ "feature/unit-test", "main", "release/1.0.3", "release/1.0.4"] + branches: [ "feature/unit-test", "main", "release/1.0.3"] pull_request: - branches: [ "feature/unit-test", "main", "release/1.0.3", "release/1.0.4" ] + branches: [ "feature/unit-test", "main", "release/1.0.3" ] jobs: build: From a8497001adbddea4516f46e716d60ba2140e7767 Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Mon, 1 Jul 2024 10:30:00 +0300 Subject: [PATCH 04/11] [ZEUS-4454] Added strategy to run tests only for IOS --- .github/workflows/swift.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 981ded6..efa2a6a 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -13,6 +13,9 @@ jobs: build: runs-on: macos-latest + strategy: + matrix: + platform: [ ios ] steps: - uses: actions/checkout@v4 From 8f671334623b68046ff433f99ac35adeef959a6b Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Mon, 1 Jul 2024 10:37:54 +0300 Subject: [PATCH 05/11] [ZEUS-4454] Added logic to clean derived data before tests --- .github/workflows/swift.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index efa2a6a..cffcada 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -18,6 +18,10 @@ jobs: platform: [ ios ] steps: + + - name: Clean DerivedData + run: rm -rf ~/Library/Developer/Xcode/DerivedData + - uses: actions/checkout@v4 - name: Build and run tests run: xcodebuild test -scheme PlaybackSDK -destination 'platform=iOS Simulator,name=iPhone 13' From 84cbddcc547485ccc4ea971bf08b71673394955e Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Mon, 1 Jul 2024 10:47:38 +0300 Subject: [PATCH 06/11] [ZEUS-4454] Added script to generate missing file for Folder structure --- .github/workflows/swift.yml | 5 +++++ generate_folder_structure.sh | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 generate_folder_structure.sh diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index cffcada..f32fc53 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -22,6 +22,11 @@ jobs: - name: Clean DerivedData run: rm -rf ~/Library/Developer/Xcode/DerivedData + - name: Checkout code - uses: actions/checkout@v4 + + - name: Generate Folder Structure + run: bash generate_folder_structure.sh + - name: Build and run tests run: xcodebuild test -scheme PlaybackSDK -destination 'platform=iOS Simulator,name=iPhone 13' diff --git a/generate_folder_structure.sh b/generate_folder_structure.sh new file mode 100644 index 0000000..99d99ee --- /dev/null +++ b/generate_folder_structure.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "# Folder Structure" > Tests/PlaybackSDKTests/Folder\ Structure.md +echo "" >> Tests/PlaybackSDKTests/Folder\ Structure.md +echo "This file represents the folder structure of the project." >> Tests/PlaybackSDKTests/Folder\ Structure.md +echo "You can update it with the actual structure if needed." >> Tests/PlaybackSDKTests/Folder\ Structure.md From 7d2732e38cce61087421a87e00c1e03dcaa98772 Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Mon, 1 Jul 2024 10:48:51 +0300 Subject: [PATCH 07/11] [ZEUS-4454] Fix --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index f32fc53..8f50a01 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -23,7 +23,7 @@ jobs: run: rm -rf ~/Library/Developer/Xcode/DerivedData - name: Checkout code - - uses: actions/checkout@v4 + uses: actions/checkout@v4 - name: Generate Folder Structure run: bash generate_folder_structure.sh From 97c71555368f048ccc7891adc106a66e6419f205 Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Mon, 1 Jul 2024 10:59:45 +0300 Subject: [PATCH 08/11] [ZEUS-4454] Added missing Folder Structure.md --- Tests/PlaybackSDKTests/Folder Structure.md | 1 + generate_folder_structure.sh | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 Tests/PlaybackSDKTests/Folder Structure.md diff --git a/Tests/PlaybackSDKTests/Folder Structure.md b/Tests/PlaybackSDKTests/Folder Structure.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Tests/PlaybackSDKTests/Folder Structure.md @@ -0,0 +1 @@ + diff --git a/generate_folder_structure.sh b/generate_folder_structure.sh index 99d99ee..fe43922 100644 --- a/generate_folder_structure.sh +++ b/generate_folder_structure.sh @@ -1,6 +1,13 @@ #!/bin/bash -echo "# Folder Structure" > Tests/PlaybackSDKTests/Folder\ Structure.md -echo "" >> Tests/PlaybackSDKTests/Folder\ Structure.md -echo "This file represents the folder structure of the project." >> Tests/PlaybackSDKTests/Folder\ Structure.md -echo "You can update it with the actual structure if needed." >> Tests/PlaybackSDKTests/Folder\ Structure.md +# Determine the current working directory +CURRENT_DIR=$(pwd) + +# Create the Folder Structure.md file in the specified directory +mkdir -p "$CURRENT_DIR/Tests/PlaybackSDKTests" +echo "# Folder Structure" > "$CURRENT_DIR/Tests/PlaybackSDKTests/Folder Structure.md" +echo "" >> "$CURRENT_DIR/Tests/PlaybackSDKTests/Folder Structure.md" +echo "This file represents the folder structure of the project." >> "$CURRENT_DIR/Tests/PlaybackSDKTests/Folder Structure.md" +echo "You can update it with the actual structure if needed." >> "$CURRENT_DIR/Tests/PlaybackSDKTests/Folder Structure.md" + +echo "Folder Structure.md generated successfully in $CURRENT_DIR/Tests/PlaybackSDKTests" From 16cf1166011536522c6d5a0bbff6539d9cb0eb44 Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Mon, 1 Jul 2024 11:24:10 +0300 Subject: [PATCH 09/11] [ZEUS-4454] Fixing IOS version --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 8f50a01..8356d87 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -29,4 +29,4 @@ jobs: run: bash generate_folder_structure.sh - name: Build and run tests - run: xcodebuild test -scheme PlaybackSDK -destination 'platform=iOS Simulator,name=iPhone 13' + run: xcodebuild test -scheme PlaybackSDK -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' From a9c9283eb4b1e04cada29005ac51d072c48eefc9 Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Tue, 2 Jul 2024 10:53:34 +0300 Subject: [PATCH 10/11] [ZEUS-4454] Code style fixes suggested by @artem-y-pamediagroup --- Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift b/Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift index f73efce..6ab902c 100644 --- a/Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift +++ b/Tests/PlaybackSDKTests/PlayBackSDKManagerTests.swift @@ -130,8 +130,8 @@ class PlayBackSDKManagerTests: XCTestCase { XCTFail("Empty entry id provided but got HLS stream") case .failure(let error): switch error { - case .networkError(_): - hlsExpectation.fulfill() + case .networkError(_): + hlsExpectation.fulfill() default: hlsExpectation.fulfill() } From cc83fd446b2445741bb962a3f6219028316ae677 Mon Sep 17 00:00:00 2001 From: Oleksandr Kharchenko Date: Tue, 2 Jul 2024 10:57:30 +0300 Subject: [PATCH 11/11] [ZEUS-4454] Updated trigger branch names --- .github/workflows/swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 8356d87..b3b165f 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -5,9 +5,9 @@ name: SPM Build and Test on: push: - branches: [ "feature/unit-test", "main", "release/1.0.3"] + branches: [ "feature/unit-test", "main", "release/*"] pull_request: - branches: [ "feature/unit-test", "main", "release/1.0.3" ] + branches: [ "feature/unit-test", "main", "release/*" ] jobs: build: