You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: media_tests.rs
    path of file: ./repos/dim/dim-database/src/tests
    
    the code of the file until where you have to start completion: use crate::get_conn_memory;
use crate::library;
use crate::media;
use crate::write_tx;

use super::library_tests::create_test_library;
use super::mediafile_tests::insert_mediafile_with_mediaid;

pub async fn insert_media(conn: &mut crate::Transaction<'_>) -> i64 {
    let media = media::InsertableMedia {
        library_id: 1,
        name: "TestMedia".into(),
        description: None,
        rating: Some(10.0),
        year: Some(2020),
        added: "Test".into(),
        poster: None,
      
    
async fn test_delete_by_lib() {
    let mut conn = get_conn_memory().await.unwrap().writer().lock_owned().await;
    let mut tx = write_tx(&mut conn).await.unwrap();
    let library_id = create_test_library(&mut tx).await;
    insert_many(&mut tx, 10).await;

    let result = media::Media::get_all(&mut tx, library_id).await.unwrap();
    assert_eq!(result.len(), 10);

    let result = media::Media::delete_by_lib_id(&mut tx, library_id)
        .await
        .unwrap();
    assert_eq!(result, 10);

    let result = media::Media::get_all(&mut tx, library_id).await.unwrap();
    assert!(result.is_empty());
}