in OSSSwiftDemo/OSSSwiftDemoTests/OSSExceptionalTests.swift [88:110]
func testAPI_putObjectWithErrorOfNoCredentialProvier() -> Void {
let provider = OSSAuthCredentialProvider(authServerUrl: "")
let wrongClient = OSSClient(endpoint: OSS_ENDPOINT, credentialProvider: provider)
let request = OSSPutObjectRequest()
let fileName = "swift"
let fileExtension = "pdf"
request.bucketName = "oss-testcase-unexist-bucket"
request.uploadingFileURL = Bundle.main.url(forResource: fileName, withExtension: fileExtension)!
request.objectKey = fileName + "." + fileExtension
request.objectMeta = ["x-oss-meta-name1": "value1"];
request.contentType = "application/pdf"
request.uploadProgress = {(bytesSent, totalByteSent, totalBytesExpectedToSend) ->Void in
print("bytesSent: \(bytesSent),totalByteSent: \(totalByteSent),totalBytesExpectedToSend: \(totalBytesExpectedToSend)")
}
let task = wrongClient.putObject(request)
task.continue({ (t) -> Any? in
XCTAssertNotNil(t.error)
let error = t.error! as NSError
XCTAssertEqual(OSSClientErrorCODE.codeSignFailed.rawValue, error.code)
return nil
}).waitUntilFinished()
}