fix: return string instead of pathbuf

This commit is contained in:
Aravinth Manivannan 2023-02-11 19:39:50 +05:30
parent df1edefb9d
commit 3f088a8cb8
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
4 changed files with 8 additions and 6 deletions

View file

@ -78,7 +78,7 @@ pub trait Federate: Sync + Send {
async fn tar(&self) -> Result<PathBuf, Self::Error>; async fn tar(&self) -> Result<PathBuf, Self::Error>;
/// get latest tar ball /// get latest tar ball
async fn latest_tar(&self) -> Result<PathBuf, Self::Error>; async fn latest_tar(&self) -> Result<String, Self::Error>;
} }
pub fn get_hostname(url: &Url) -> &str { pub fn get_hostname(url: &Url) -> &str {

View file

@ -53,9 +53,9 @@ pub async fn adding_forge_works<'a, T: Federate>(
.unwrap()); .unwrap());
// tar() // tar()
let tar = ff.tar().await.unwrap(); let tar = ff.tar().await.unwrap().to_str().unwrap().to_string();
let latest = ff.latest_tar().await.unwrap(); let latest = ff.latest_tar().await.unwrap();
assert_eq!(tar, latest); assert!(tar.contains(&latest));
// delete repository // delete repository
ff.delete_repository(add_repo_msg.owner, add_repo_msg.name, &add_repo_msg.url) ff.delete_repository(add_repo_msg.owner, add_repo_msg.name, &add_repo_msg.url)

View file

@ -258,7 +258,7 @@ impl Federate for PccFederate {
} }
/// get latest tar ball /// get latest tar ball
async fn latest_tar(&self) -> Result<PathBuf, Self::Error> { async fn latest_tar(&self) -> Result<String, Self::Error> {
use std::fs::File; use std::fs::File;
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
@ -293,7 +293,6 @@ impl Federate for PccFederate {
times.sort(); times.sort();
let latest = times.pop().unwrap(); let latest = times.pop().unwrap();
let latest = Path::new(&self.base_dir).join(format!("{}.tar", latest.to_string())); Ok(format!("{}.tar", latest))
Ok(latest)
} }
} }

View file

@ -37,6 +37,7 @@ async fn everything_works() {
let create_forge_msg = CreateForge { let create_forge_msg = CreateForge {
url: url.clone(), url: url.clone(),
forge_type: ForgeImplementation::Gitea, forge_type: ForgeImplementation::Gitea,
import: false,
}; };
let add_user_msg = AddUser { let add_user_msg = AddUser {
@ -44,6 +45,7 @@ async fn everything_works() {
html_link: HTML_PROFILE_URL, html_link: HTML_PROFILE_URL,
profile_photo: None, profile_photo: None,
username: USERNAME, username: USERNAME,
import: false,
}; };
let add_repo_msg = AddRepository { let add_repo_msg = AddRepository {
@ -54,6 +56,7 @@ async fn everything_works() {
website: None, website: None,
description: None, description: None,
url: url.clone(), url: url.clone(),
import: false,
}; };
let pcc = PccFederate::new(tmp_dir.to_str().unwrap().to_string()) let pcc = PccFederate::new(tmp_dir.to_str().unwrap().to_string())