fix: Refactored grammatical errors

This commit is contained in:
dat-adi 2022-07-05 14:05:57 +05:30
parent db1d7657a7
commit a65115bfeb
9 changed files with 28 additions and 27 deletions

View file

@ -182,13 +182,13 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
/// delete DNS challenge /// delete DNS challenge
async fn delete_dns_challenge(&self, key: &str) -> DBResult<()>; async fn delete_dns_challenge(&self, key: &str) -> DBResult<()>;
/// create forge isntance /// create forge instance
async fn create_forge_isntance(&self, f: &CreateForge) -> DBResult<()>; async fn create_forge_instance(&self, f: &CreateForge) -> DBResult<()>;
/// get forge isntance data /// get forge instance data
async fn get_forge(&self, hostname: &str) -> DBResult<Forge>; async fn get_forge(&self, hostname: &str) -> DBResult<Forge>;
/// delete forge isntance /// delete forge instance
async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()>; async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()>;
/// check if a forge instance exists /// check if a forge instance exists

View file

@ -27,10 +27,10 @@ pub async fn adding_forge_works<'a, T: SCDatabase>(
add_repo_msg: AddRepository<'a>, add_repo_msg: AddRepository<'a>,
) { ) {
let _ = db.delete_forge_instance(create_forge_msg.hostname).await; let _ = db.delete_forge_instance(create_forge_msg.hostname).await;
db.create_forge_isntance(&create_forge_msg).await.unwrap(); db.create_forge_instance(&create_forge_msg).await.unwrap();
assert!( assert!(
db.forge_exists(create_forge_msg.hostname).await.unwrap(), db.forge_exists(create_forge_msg.hostname).await.unwrap(),
"forge creation failed, forge existance check failure" "forge creation failed, forge exinstance check failure"
); );
{ {

View file

@ -111,7 +111,7 @@ impl SCDatabase for Database {
} }
} }
/// delete forge isntance /// delete forge instance
async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()> { async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()> {
sqlx::query!( sqlx::query!(
"DELETE FROM starchart_forges WHERE hostname = ($1)", "DELETE FROM starchart_forges WHERE hostname = ($1)",
@ -123,8 +123,8 @@ impl SCDatabase for Database {
Ok(()) Ok(())
} }
/// create forge isntance DB /// create forge instance DB
async fn create_forge_isntance(&self, f: &CreateForge) -> DBResult<()> { async fn create_forge_instance(&self, f: &CreateForge) -> DBResult<()> {
let now = now_unix_time_stamp(); let now = now_unix_time_stamp();
let forge_type = f.forge_type.to_str(); let forge_type = f.forge_type.to_str();
sqlx::query!( sqlx::query!(
@ -142,7 +142,7 @@ impl SCDatabase for Database {
Ok(()) Ok(())
} }
/// get forge isntance data /// get forge instance data
async fn get_forge(&self, hostname: &str) -> DBResult<Forge> { async fn get_forge(&self, hostname: &str) -> DBResult<Forge> {
struct InnerForge { struct InnerForge {
hostname: String, hostname: String,

View file

@ -36,10 +36,10 @@ pub trait Federate: Sync + Send {
/// utility method to remove file/dir /// utility method to remove file/dir
async fn rm_util(&self, path: &Path) -> Result<(), Self::Error>; async fn rm_util(&self, path: &Path) -> Result<(), Self::Error>;
/// create forge isntance /// create forge instance
async fn create_forge_isntance(&self, f: &CreateForge<'_>) -> Result<(), Self::Error>; async fn create_forge_instance(&self, f: &CreateForge<'_>) -> Result<(), Self::Error>;
/// delete forge isntance /// delete forge instance
async fn delete_forge_instance(&self, hostname: &str) -> Result<(), Self::Error>; async fn delete_forge_instance(&self, hostname: &str) -> Result<(), Self::Error>;
/// check if a forge instance exists /// check if a forge instance exists
@ -48,10 +48,10 @@ pub trait Federate: Sync + Send {
/// check if an user exists. /// check if an user exists.
async fn user_exists(&self, username: &str, hostname: &str) -> Result<bool, Self::Error>; async fn user_exists(&self, username: &str, hostname: &str) -> Result<bool, Self::Error>;
/// create user isntance /// create user instance
async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error>; async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error>;
/// add repository isntance /// add repository instance
async fn create_repository(&self, f: &AddRepository<'_>) -> Result<(), Self::Error>; async fn create_repository(&self, f: &AddRepository<'_>) -> Result<(), Self::Error>;
/// check if a repository exists. /// check if a repository exists.

View file

@ -27,7 +27,7 @@ pub async fn adding_forge_works<'a, T: Federate>(
) { ) {
let _ = ff.delete_forge_instance(create_forge_msg.hostname).await; let _ = ff.delete_forge_instance(create_forge_msg.hostname).await;
assert!(!ff.forge_exists(&create_forge_msg.hostname).await.unwrap()); assert!(!ff.forge_exists(&create_forge_msg.hostname).await.unwrap());
ff.create_forge_isntance(&create_forge_msg).await.unwrap(); ff.create_forge_instance(&create_forge_msg).await.unwrap();
assert!(ff.forge_exists(&create_forge_msg.hostname).await.unwrap()); assert!(ff.forge_exists(&create_forge_msg.hostname).await.unwrap());
// add user // add user

View file

@ -128,14 +128,14 @@ impl Federate for PccFederate {
Ok(()) Ok(())
} }
/// create forge isntance /// create forge instance
async fn create_forge_isntance(&self, f: &CreateForge<'_>) -> FResult<()> { async fn create_forge_instance(&self, f: &CreateForge<'_>) -> FResult<()> {
let path = self.get_instance_path(f.hostname, true).await?; let path = self.get_instance_path(f.hostname, true).await?;
self.write_util(f, &path.join(INSTANCE_INFO_FILE)).await?; self.write_util(f, &path.join(INSTANCE_INFO_FILE)).await?;
Ok(()) Ok(())
} }
/// delete forge isntance /// delete forge instance
async fn delete_forge_instance(&self, hostname: &str) -> FResult<()> { async fn delete_forge_instance(&self, hostname: &str) -> FResult<()> {
let path = self.get_instance_path(hostname, false).await?; let path = self.get_instance_path(hostname, false).await?;
self.rm_util(&path).await self.rm_util(&path).await
@ -163,13 +163,13 @@ impl Federate for PccFederate {
} }
} }
/// create user isntance /// create user instance
async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error> { async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error> {
let path = self.get_user_path(f.username, f.hostname, true).await?; let path = self.get_user_path(f.username, f.hostname, true).await?;
self.write_util(f, &path.join(USER_INFO_FILE)).await self.write_util(f, &path.join(USER_INFO_FILE)).await
} }
/// add repository isntance /// add repository instance
async fn create_repository(&self, f: &AddRepository<'_>) -> Result<(), Self::Error> { async fn create_repository(&self, f: &AddRepository<'_>) -> Result<(), Self::Error> {
let path = self let path = self
.get_repo_path(f.name, f.owner, f.hostname, true) .get_repo_path(f.name, f.owner, f.hostname, true)

View file

@ -193,11 +193,11 @@ def add_tag(repo: str, client: HTMLClient):
if __name__ == "__main__": if __name__ == "__main__":
for i in range(TOTAL_NUM_REPOS): for i in range(TOTAL_NUM_REPOS):
REPOS.append(f"reopsitory_{i}") REPOS.append(f"repository_{i}")
check_online() check_online()
print("Instace online") print("Instance online")
install() install()
print("Instace configured and installed") print("Instance configured and installed")
client = HTMLClient() client = HTMLClient()
count = 0 count = 0
while True: while True:

View file

@ -32,6 +32,7 @@ pub mod routes;
pub mod settings; pub mod settings;
pub mod spider; pub mod spider;
pub mod static_assets; pub mod static_assets;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
pub mod utils; pub mod utils;

View file

@ -37,7 +37,7 @@ impl Ctx {
hostname, hostname,
forge_type: gitea.forge_type(), forge_type: gitea.forge_type(),
}; };
db.create_forge_isntance(&msg).await.unwrap(); db.create_forge_instance(&msg).await.unwrap();
} else { } else {
if !federate.forge_exists(hostname).await.unwrap() { if !federate.forge_exists(hostname).await.unwrap() {
let forge = db.get_forge(hostname).await.unwrap(); let forge = db.get_forge(hostname).await.unwrap();
@ -45,7 +45,7 @@ impl Ctx {
hostname, hostname,
forge_type: forge.forge_type, forge_type: forge.forge_type,
}; };
federate.create_forge_isntance(&msg).await.unwrap(); federate.create_forge_instance(&msg).await.unwrap();
} }
} }
@ -135,7 +135,7 @@ mod tests {
.unwrap()); .unwrap());
assert!(db.user_exists(GITEA_USERNAME, None).await.unwrap()); assert!(db.user_exists(GITEA_USERNAME, None).await.unwrap());
for i in 0..100 { for i in 0..100 {
let repo = format!("reopsitory_{i}"); let repo = format!("repository_{i}");
assert!(db assert!(db
.repository_exists(&repo, GITEA_USERNAME, hostname.as_str()) .repository_exists(&repo, GITEA_USERNAME, hostname.as_str())
.await .await