This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from vimeo/release/2.1.0
VIM-6928: Version bump 2.1.0, last release prior to Swift 4.2 upgrade
- Loading branch information
Showing
128 changed files
with
3,932 additions
and
2,591 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
Examples/VimeoUpload-iOS/VimeoUpload-iOSTests/StreamingUploadStrategyTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// | ||
// StreamingUploadStrategyTests.swift | ||
// VimeoUpload-iOSTests | ||
// | ||
// Created by Nguyen, Van on 11/13/18. | ||
// Copyright © 2018 Vimeo. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
import XCTest | ||
@testable import VimeoNetworking | ||
@testable import VimeoUpload | ||
|
||
class StreamingUploadStrategyTests: XCTestCase | ||
{ | ||
func test_uploadLink_returnsStreamingLink_whenStreamingLinkIsAvailable() | ||
{ | ||
let video = self.videoObject(fromResponseWithFile: "clip_streaming.json") | ||
|
||
XCTAssertEqual(try StreamingUploadStrategy.uploadLink(from: video), "https://www.google.com", "`uploadLink` should have returned a streaming link.") | ||
} | ||
|
||
func test_uploadLink_throwsWrongTypeError_whenUploadApproachIsDifferentFromStreaming() | ||
{ | ||
let video = self.videoObject(fromResponseWithFile: "clip_tus.json") | ||
|
||
XCTAssertThrowsError(try StreamingUploadStrategy.uploadLink(from: video), "`uploadLink` should have thrown.") { error in | ||
XCTAssertEqual(error as? UploadLinkError, .wrongType, "The error should have been `wrongType`.") | ||
} | ||
} | ||
|
||
func test_uploadLink_throwsUnavailableError_whenStreamingLinkIsNotAvailable() | ||
{ | ||
let video = self.videoObject(fromResponseWithFile: "clip_streaming_no_link.json") | ||
|
||
XCTAssertThrowsError(try StreamingUploadStrategy.uploadLink(from: video), "`uploadLink` should have thrown.") { error in | ||
XCTAssertEqual(error as? UploadLinkError, .unavailable, "The error should have been `unavailable`.") | ||
} | ||
} | ||
|
||
func test_uploadRequest_throwsError_whenRequestSerializerIsNotAvailable() | ||
{ | ||
guard let fileUrl = Bundle(for: type(of: self)).url(forResource: "wide_worlds", withExtension: "mp4") else | ||
{ | ||
fatalError("Error: Cannot get file's URL.") | ||
} | ||
|
||
let video = self.videoObject(fromResponseWithFile: "clip_streaming.json") | ||
|
||
guard let uploadLink = video.upload?.uploadLink else | ||
{ | ||
fatalError("Error: Cannot get an upload link.") | ||
} | ||
|
||
XCTAssertThrowsError(try StreamingUploadStrategy.uploadRequest(requestSerializer: nil, fileUrl: fileUrl, uploadLink: uploadLink), "`uploadRequest` should have thrown.") | ||
} | ||
|
||
private func videoObject(fromResponseWithFile fileName: String) -> VIMVideo | ||
{ | ||
do | ||
{ | ||
let bundle = Bundle(for: type(of: self)) | ||
|
||
guard let jsonUrl = bundle.url(forResource: fileName, withExtension: nil) else | ||
{ | ||
fatalError("Error: File not found.") | ||
} | ||
|
||
let data = try Data(contentsOf: jsonUrl) | ||
|
||
guard let dictionary = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] else | ||
{ | ||
fatalError("Error: Dictionary object cannot be created.") | ||
} | ||
|
||
return try VIMObjectMapper.mapObject(responseDictionary: dictionary) as VIMVideo | ||
} | ||
catch let error | ||
{ | ||
fatalError("Error: \(error.localizedDescription)") | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
Examples/VimeoUpload-iOS/VimeoUpload-iOSTests/URL+MIMETypeTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// URL+MIMETypeTests.swift | ||
// VimeoUpload-iOSTests | ||
// | ||
// Created by Lehrer, Nicole on 2/6/19. | ||
// Copyright © 2019 Alfie Hanssen. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
class URL_MIMETypeTests: XCTestCase { | ||
|
||
func test_MIMEType_returnsVideoMP4() { | ||
let urlMP4 = URL(string: "testFile.mp4") | ||
XCTAssertTrue(try urlMP4?.mimeType() == "video/mp4") | ||
} | ||
|
||
func test_MIMEType_returnsVideoQuicktime(){ | ||
let urlQuickTime = URL(string: "testFile.mov") | ||
XCTAssertTrue(try urlQuickTime?.mimeType() == "video/quicktime") | ||
} | ||
|
||
func test_MIMEType_returnsVideoAVI(){ | ||
let urlAVI = URL(string: "testFile.avi") | ||
XCTAssertTrue(try urlAVI?.mimeType() == "video/avi") | ||
} | ||
|
||
func test_MIMEType_throwsError() | ||
{ | ||
let urlInvalid = URL(string: "") | ||
let mimeTypeError = NSError(domain: URL.MIMETypeError.Domain, code: URL.MIMETypeError.Code, userInfo: URL.MIMETypeError.UserInfo) | ||
|
||
do | ||
{ | ||
_ = try urlInvalid?.mimeType() | ||
} | ||
catch let error | ||
{ | ||
XCTAssertEqual((error as NSError), mimeTypeError) | ||
} | ||
} | ||
} |
Oops, something went wrong.