Repository: bottlerocket-os/bottlerocket
File: sources/settings-migrations/v1.40.0/kubelet-device-plugins-cdi-settings/src/main.rs (Rust)

Code before:
    use std::collections::HashMap;
    use serde_json::Value;

    #[test]
    fn forward_test() {
        let data = MigrationData {
            data: hashmap! {
                "hi".into() => "cdi-cri".into(),
            },
            metadata: HashMap::new(),
        };
        let result = ReplaceDeviceListStrategy(&["hi"]).forward(data).unwrap();
        assert_eq!(
            result.data,
            hashmap! {
                "hi".into() => "cdi-cri".into(),
            }
        );
    }

    #[test]
    fn backward_test() {
        struct TestCase {
            input: MigrationData,
            expected: HashMap<String, Value>,
        }

        let test_cases = vec![
            TestCase {
                input: MigrationData {
                    data: hashmap! {
                        "hi".into() => vec!["cdi-cri"].into(),
                    },
                    metadata: HashMap::new(),
                },
                expected: hashmap! {
                    "hi".into() => "volume-mounts".into(),
                },
            },
            TestCase {
                input: MigrationData {
                    data: hashmap! {
                        "hi".into() => Vec::<String>::new().into(),
                    },
                    metadata: HashMap::new(),
                },
                expected: hashmap! {
                    "hi".into() => "volume-mounts".into(),
                },
            },
            TestCase {

Review comment (suggestion):
You don't need a struct, you can use a `tuple`:

```
(MigrationData, HashMap<String, Value>)
```

Code after:

    #[test]
    fn forward_test() {
        let data = MigrationData {
            data: hashmap! {
                DEVICE_LIST_STRATEGY_SETTING.into() => "volume-mounts".into(),
            },
            metadata: HashMap::new(),
        };
        let result = ReplaceDeviceListStrategy.forward(data).unwrap();
        assert_eq!(
            result.data,
            hashmap! {
                DEVICE_LIST_STRATEGY_SETTING.into() => "volume-mounts".into(),
            }
        );
    }

    #[test]
    fn backward_test() {
        let test_cases: Vec<(MigrationData, HashMap<String, Value>)> = vec![
            (
                MigrationData {
                    data: hashmap! {
                        DEVICE_LIST_STRATEGY_SETTING.into() => vec!["cdi-cri"].into(),
                    },
                    metadata: HashMap::new(),
                },
                hashmap! {
                    DEVICE_LIST_STRATEGY_SETTING.into() => "volume-mounts".into(),
                },
            ),
            (
                MigrationData {
                    data: hashmap! {
                        DEVICE_LIST_STRATEGY_SETTING.into() => Vec::<String>::new().into(),
                    },
                    metadata: HashMap::new(),
                },
                hashmap! {
                    DEVICE_LIST_STRATEGY_SETTING.into() => "volume-mounts".into(),
                },
            ),
            (
                MigrationData {
                    data: hashmap! {
                        DEVICE_LIST_STRATEGY_SETTING.into() => vec!["volume-mounts", "envvar"].into(),
                    },
                    metadata: HashMap::new(),
                },
                hashmap! {