Skip to content

Commit

Permalink
Improve AtomGit unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahao6635 committed Feb 27, 2024
1 parent e109b54 commit aca0ec6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/scm/driver/atomgit/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<GithubContentEndpoint>(&path, Some(options))?;
let res = self.client.get::<AtomGitContentEndpoint>(&path, Some(options))?;

if let Some(content) = res.data {
Ok(content.try_into()?)
Expand All @@ -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::<GithubFileEndpoint>(&path, Some(options))?;
let res = self.client.get::<AtomGitFileEndpoint>(&path, Some(options))?;

if let Some(list) = res.data {
return Ok(list.iter().map(|v| v.into()).collect());
Expand All @@ -80,16 +80,16 @@ impl TryFrom<AtomGitContent> 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;
}

Expand All @@ -115,8 +115,8 @@ impl From<&AtomGitFile> for File {
}
}

struct GithubFileEndpoint;
struct AtomGitFileEndpoint;

impl Endpoint for GithubFileEndpoint {
impl Endpoint for AtomGitFileEndpoint {
type Output = Vec<AtomGitFile>;
}
6 changes: 3 additions & 3 deletions src/scm/driver/atomgit/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<Repository>> {
let path = ATOMGIT_PATH_REPOS.replace("{repo}", repo);
let res = self.client.get::<GithubRepoEndpoint>(&path, None)?;
let res = self.client.get::<AtomGitRepoEndpoint>(&path, None)?;

Ok(res.data.map(|v| v.into()))
}
Expand Down Expand Up @@ -78,8 +78,8 @@ impl From<AtomGitRepository> for Repository {
}
}

struct GithubRepoEndpoint;
struct AtomGitRepoEndpoint;

impl Endpoint for GithubRepoEndpoint {
impl Endpoint for AtomGitRepoEndpoint {
type Output = AtomGitRepository;
}

0 comments on commit aca0ec6

Please sign in to comment.