refactor: Don't use traits where it's not necessary (#6567)

Traits are bad for readability and compile times.
This commit is contained in:
Hocuri
2025-02-25 19:52:17 +01:00
committed by GitHub
parent c5cf16f32a
commit 9f67d0f905
8 changed files with 58 additions and 51 deletions

View File

@@ -282,15 +282,22 @@ async fn test_file_handling() {
};
}
assert!(delete_file(context, "$BLOBDIR/lkqwjelqkwlje")
assert!(delete_file(context, Path::new("$BLOBDIR/lkqwjelqkwlje"))
.await
.is_err());
assert!(write_file(context, "$BLOBDIR/foobar", b"content")
.await
.is_ok());
assert!(
write_file(context, Path::new("$BLOBDIR/foobar"), b"content")
.await
.is_ok()
);
assert!(file_exist!(context, "$BLOBDIR/foobar"));
assert!(!file_exist!(context, "$BLOBDIR/foobarx"));
assert_eq!(get_filebytes(context, "$BLOBDIR/foobar").await.unwrap(), 7);
assert_eq!(
get_filebytes(context, Path::new("$BLOBDIR/foobar"))
.await
.unwrap(),
7
);
let abs_path = context
.get_blobdir()
@@ -300,19 +307,23 @@ async fn test_file_handling() {
assert!(file_exist!(context, &abs_path));
assert!(delete_file(context, "$BLOBDIR/foobar").await.is_ok());
assert!(create_folder(context, "$BLOBDIR/foobar-folder")
assert!(delete_file(context, Path::new("$BLOBDIR/foobar"))
.await
.is_ok());
assert!(create_folder(context, Path::new("$BLOBDIR/foobar-folder"))
.await
.is_ok());
assert!(file_exist!(context, "$BLOBDIR/foobar-folder"));
assert!(delete_file(context, "$BLOBDIR/foobar-folder")
assert!(delete_file(context, Path::new("$BLOBDIR/foobar-folder"))
.await
.is_err());
let fn0 = "$BLOBDIR/data.data";
assert!(write_file(context, &fn0, b"content").await.is_ok());
assert!(write_file(context, Path::new(fn0), b"content")
.await
.is_ok());
assert!(delete_file(context, &fn0).await.is_ok());
assert!(delete_file(context, Path::new(fn0)).await.is_ok());
assert!(!file_exist!(context, &fn0));
}