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: tests.rs
    path of file: ./repos/materialize/src/catalog/src/durable/upgrade
    
    the code of the file until where you have to start completion: // Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use once_cell::sync::Lazy;
use std::collections::BTreeSet;
use std::fs;
use std::io::Write;

use mz_persist_types::Codec;
use mz_storage_types::sources::SourceData;

use crate::durable::impls::persist::state_update::StateUpdateKindRaw;
use crate::durable::upgrade::AllVersionsStateUpdateKind;

static PROTO_DIRECTORY: Lazy<String> =
    Lazy::new(|| format!("{}/protos", env!("CARGO_MANIFEST_DIR")));
const PROTO_EXT: &str = "proto";

static SNAPSHOT_DIRECTORY: Lazy<String> = Lazy::new(|| {
    format!(
        "{}/src/durable/upgrade/snapshots",
        env!("CARGO_MANIFEST_DIR")
    )
});
const SNAPSHOT_EXT: &str = "txt";

#[mz_ore::test]

    
fn generate_missing_encodings() {
    let protos: BTreeSet<_> = read_file_names(&PROTO_DIRECTORY, PROTO_EXT)
        .filter(|name| name != "objects")
        .collect();

    let snapshots: BTreeSet<_> = read_file_names(&SNAPSHOT_DIRECTORY, SNAPSHOT_EXT).collect();

    let unknown_snapshots: Vec<_> = snapshots.difference(&protos).collect();
    if !unknown_snapshots.is_empty() {
        panic!("Have snapshots, but no proto files on disk? {unknown_snapshots:#?}");
    }

    let base64_config = base64::Config::new(base64::CharacterSet::Standard, true);

    for to_encode in protos.difference(&snapshots) {
        let mut file = fs::File::options()
            .create_new(true)
            .write(true)
            .open(format!("{}/{}.txt", *SNAPSHOT_DIRECTORY, to_encode))
            .expect("file exists");
        let encoded_datas = AllVersionsStateUpdateKind::arbitrary_vec(to_encode)
            .expect("valid version")
            .into_iter()
            .map(|kind| kind.raw())
            .map(SourceData::from)
            .map(|source_data| {
                let mut buf = Vec::new();
                source_data.encode(&mut buf);
                buf
            })
            .map(|buf| {
                let mut encoded = String::new();
                base64::encode_config_buf(buf.as_slice(), base64_config, &mut encoded);
                encoded
            });
        for encoded_data in encoded_datas {
            write!(&mut file, "{encoded_data}\n").expect("unable to write file");
        }
    }
}