Skip to content

Commit

Permalink
update: cleanup tests & imports
Browse files Browse the repository at this point in the history
  • Loading branch information
GoranBrkuljan committed Jan 29, 2025
1 parent b66916b commit f0811f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions charybdis-migrate/src/args.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use clap::Parser;
use std::env;
use std::path::PathBuf;

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
Expand Down Expand Up @@ -67,5 +66,7 @@ impl Default for Args {
pub(crate) fn get_current_dir() -> String {
let path = env::current_dir().expect("Failed to find project root: Could not get current directory");

PathBuf::from(path).to_str().unwrap().to_string()
path.to_str()
.expect("Failed to find project root: Could not convert path to string")
.to_string()
}
4 changes: 3 additions & 1 deletion charybdis-parser/src/schema/code_schema/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ fn extract_schema_object(item_struct: &ItemStruct, model_macro: &ModelMacro) ->

for field in db_fields {
let field_name = field.ident.to_string();
let field_type = field.column_type_override.unwrap_or_else(|| type_with_arguments(&field.ty_path));
let field_type = field
.column_type_override
.unwrap_or_else(|| type_with_arguments(&field.ty_path));
let is_static = schema_object.static_columns.contains(&field_name);

schema_object.push_field(field_name, field_type, is_static);
Expand Down
11 changes: 5 additions & 6 deletions charybdis/tests/integrations/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ async fn model_mutation() {
assert_eq!(user, new_user);

user.bio = Some("I like beer".to_string());
if let Some(ref mut address) = user.address {
address.addr_type = AddressTypeCustomField::HomeAddress;
} else {panic!("homer should have address")};
user.address.as_mut().expect("homer should have address").addr_type = AddressTypeCustomField::HomeAddress;
let tag = ("Second Key".to_string(), "Second Value".to_string());
user.user_extra_data.user_tags.push(tag.clone());

Expand All @@ -42,9 +40,10 @@ async fn model_mutation() {
.expect("Failed to find user");

assert_eq!(user.bio, Some("I like beer".to_string()));
if let Some(ref address) = user.address {
assert_eq!(address.addr_type, AddressTypeCustomField::HomeAddress);
} else {panic!("homer should have address")};
assert_eq!(
user.address.as_ref().expect("homer should have address").addr_type,
AddressTypeCustomField::HomeAddress
);
assert_eq!(user.user_extra_data.user_tags.last().cloned(), Some(tag));

user.delete().execute(&db_session).await.expect("Failed to delete user");
Expand Down

0 comments on commit f0811f9

Please sign in to comment.