Skip to content

Commit

Permalink
feat(services/pcloud): setup test for pcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
hoslo committed Jan 29, 2024
1 parent 519e6e1 commit a87b3ba
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 50 deletions.
32 changes: 32 additions & 0 deletions .github/services/pcloud/pcloud/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: pcloud
description: 'Behavior test for Pcloud.'

runs:
using: "composite"
steps:
- name: Setup
uses: 1password/load-secrets-action@v1
with:
export-env: true
env:
OPENDAL_PCLOUD_ROOT: /
OPENDAL_PCLOUD_ENDPOINT: op://services/pcloud/endpoint
OPENDAL_PCLOUD_USERNAME: op://services/pcloud/username
OPENDAL_PCLOUD_PASSWORD: op://services/pcloud/password
2 changes: 2 additions & 0 deletions bindings/java/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ services-all = [
"services-onedrive",
"services-persy",
"services-postgresql",
"services-pcloud",
"services-koofr",
"services-mysql",
"services-redb",
Expand Down Expand Up @@ -135,6 +136,7 @@ services-mysql = ["opendal/services-mysql"]
services-onedrive = ["opendal/services-onedrive"]
services-persy = ["opendal/services-persy"]
services-postgresql = ["opendal/services-postgresql"]
services-pcloud = ["opendal/services-pcloud"]
services-redb = ["opendal/services-redb"]
services-redis = ["opendal/services-redis"]
services-rocksdb = ["opendal/services-rocksdb"]
Expand Down
2 changes: 2 additions & 0 deletions bindings/nodejs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ services-all = [
"services-onedrive",
"services-persy",
"services-postgresql",
"services-pcloud",
"services-mysql",
"services-redb",
"services-redis",
Expand Down Expand Up @@ -130,6 +131,7 @@ services-mysql = ["opendal/services-mysql"]
services-onedrive = ["opendal/services-onedrive"]
services-persy = ["opendal/services-persy"]
services-postgresql = ["opendal/services-postgresql"]
services-pcloud = ["opendal/services-pcloud"]
services-redb = ["opendal/services-redb"]
services-redis = ["opendal/services-redis"]
services-rocksdb = ["opendal/services-rocksdb"]
Expand Down
2 changes: 2 additions & 0 deletions bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ services-all = [
"services-onedrive",
"services-persy",
"services-postgresql",
"services-pcloud",
"services-mysql",
"services-redb",
"services-redis",
Expand Down Expand Up @@ -132,6 +133,7 @@ services-mysql = ["opendal/services-mysql"]
services-onedrive = ["opendal/services-onedrive"]
services-persy = ["opendal/services-persy"]
services-postgresql = ["opendal/services-postgresql"]
services-pcloud = ["opendal/services-pcloud"]
services-redb = ["opendal/services-redb"]
services-redis = ["opendal/services-redis"]
services-rocksdb = ["opendal/services-rocksdb"]
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ default = [
"services-webdav",
"services-webhdfs",
"services-azfile",
"services-pcloud"
]

# Build test utils or not.
Expand Down
15 changes: 12 additions & 3 deletions core/src/services/pcloud/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use serde::Deserialize;

use super::core::*;
use super::error::parse_error;
use super::error::parse_result;
use super::error::PcloudError;
use super::lister::PcloudLister;
use super::writer::PcloudWriter;
Expand Down Expand Up @@ -277,6 +278,9 @@ impl Accessor for PcloudBackend {
let resp: StatResponse =
serde_json::from_slice(&bs).map_err(new_json_deserialize_error)?;
let result = resp.result;

parse_result(result)?;

if result == 2010 || result == 2055 || result == 2002 {
return Err(Error::new(ErrorKind::NotFound, &format!("{resp:?}")));
}
Expand Down Expand Up @@ -338,9 +342,10 @@ impl Accessor for PcloudBackend {
let resp: PcloudError =
serde_json::from_slice(&bs).map_err(new_json_deserialize_error)?;
let result = resp.result;

// pCloud returns 2005 or 2009 if the file or folder is not found
if result != 0 && result != 2005 && result != 2009 {
parse_result(result)?;
// pCloud returns 2005 if the folder is not found.
// And 2009 or 2002 if the file is not found.
if result != 0 && result != 2005 && result != 2009 && result != 2002 {
return Err(Error::new(ErrorKind::Unexpected, &format!("{resp:?}")));
}

Expand Down Expand Up @@ -372,6 +377,8 @@ impl Accessor for PcloudBackend {
let resp: PcloudError =
serde_json::from_slice(&bs).map_err(new_json_deserialize_error)?;
let result = resp.result;

parse_result(result)?;
if result == 2009 || result == 2010 || result == 2055 || result == 2002 {
return Err(Error::new(ErrorKind::NotFound, &format!("{resp:?}")));
}
Expand Down Expand Up @@ -402,6 +409,8 @@ impl Accessor for PcloudBackend {
let resp: PcloudError =
serde_json::from_slice(&bs).map_err(new_json_deserialize_error)?;
let result = resp.result;

parse_result(result)?;
if result == 2009 || result == 2010 || result == 2055 || result == 2002 {
return Err(Error::new(ErrorKind::NotFound, &format!("{resp:?}")));
}
Expand Down
Loading

0 comments on commit a87b3ba

Please sign in to comment.