From aca0ec6cacc2b1ee5052b5b7e88d6fd56efe367a Mon Sep 17 00:00:00 2001 From: jiahao6635 Date: Wed, 28 Feb 2024 00:32:43 +0800 Subject: [PATCH] Improve AtomGit unit testing --- src/scm/driver/atomgit/content.rs | 14 +++++++------- src/scm/driver/atomgit/repo.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/scm/driver/atomgit/content.rs b/src/scm/driver/atomgit/content.rs index d6fe83a..34aa90b 100644 --- a/src/scm/driver/atomgit/content.rs +++ b/src/scm/driver/atomgit/content.rs @@ -35,7 +35,7 @@ impl ContentService for AtomGitContentService { .replace("{repo}", repo) .replace("{file}", file); let options = HashMap::from([("ref".to_string(), reference.to_string())]); - let res = self.client.get::(&path, Some(options))?; + let res = self.client.get::(&path, Some(options))?; if let Some(content) = res.data { Ok(content.try_into()?) @@ -53,7 +53,7 @@ impl ContentService for AtomGitContentService { .replace("{repo}", repo) .replace("{file}", path); let options = HashMap::from([("ref".to_string(), reference.to_string())]); - let res = self.client.get::(&path, Some(options))?; + let res = self.client.get::(&path, Some(options))?; if let Some(list) = res.data { return Ok(list.iter().map(|v| v.into()).collect()); @@ -80,16 +80,16 @@ impl TryFrom for Content { Ok(Self { path: val.path, data: BASE64.decode(val.content.as_bytes())?, - // the sha returned for github rest api is the blob sha, not the commit sha + // the sha returned for atomgit rest api is the blob sha, not the commit sha sha: val.sha.clone(), blob_id: val.sha, }) } } -struct GithubContentEndpoint; +struct AtomGitContentEndpoint; -impl Endpoint for GithubContentEndpoint { +impl Endpoint for AtomGitContentEndpoint { type Output = AtomGitContent; } @@ -115,8 +115,8 @@ impl From<&AtomGitFile> for File { } } -struct GithubFileEndpoint; +struct AtomGitFileEndpoint; -impl Endpoint for GithubFileEndpoint { +impl Endpoint for AtomGitFileEndpoint { type Output = Vec; } diff --git a/src/scm/driver/atomgit/repo.rs b/src/scm/driver/atomgit/repo.rs index 3c65701..851a770 100644 --- a/src/scm/driver/atomgit/repo.rs +++ b/src/scm/driver/atomgit/repo.rs @@ -30,7 +30,7 @@ impl RepositoryService for AtomGitRepoService { /// Example: https://api.atomgit.com/repos/jia-hao-li/atomgit_evaluation fn find(&self, repo: &str) -> anyhow::Result> { let path = ATOMGIT_PATH_REPOS.replace("{repo}", repo); - let res = self.client.get::(&path, None)?; + let res = self.client.get::(&path, None)?; Ok(res.data.map(|v| v.into())) } @@ -78,8 +78,8 @@ impl From for Repository { } } -struct GithubRepoEndpoint; +struct AtomGitRepoEndpoint; -impl Endpoint for GithubRepoEndpoint { +impl Endpoint for AtomGitRepoEndpoint { type Output = AtomGitRepository; }