Repository: zellij-org/zellij
File: zellij-utils/src/input/unit/layout_test.rs (Rust)

Code before:
    let layout = LayoutFromYaml::new(&path);
    let layout_template = layout.as_ref().unwrap();
    assert_eq!(layout_template.tabs.len(), 1);
}

#[test]
fn default_layout_merged_correctly() {
    let path = default_layout_dir("default.yaml".into());
    let layout_from_yaml = LayoutFromYaml::new(&path);
    let layout_template = layout_from_yaml.as_ref().unwrap();
    let tab_layout = layout_template
        .template
        .clone()
        .insert_tab_layout(Some(layout_template.tabs[0].clone()));
    let merged_layout = Layout {
        direction: Direction::Horizontal,
        borderless: false,
        parts: vec![
            Layout {
                direction: Direction::Vertical,
                borderless: true,
                parts: vec![],
                split_size: Some(SplitSize::Fixed(1)),
                run: Some(Run::Plugin(Some(RunPlugin {
                    path: "tab-bar".into(),
                    _allow_exec_host_cmd: false,
                }))),
            },
            Layout {
                direction: Direction::Vertical,
                borderless: false,
                parts: vec![],
                split_size: None,
                run: None,
            },
            Layout {
                direction: Direction::Vertical,
                borderless: true,
                parts: vec![],
                split_size: Some(SplitSize::Fixed(2)),
                run: Some(Run::Plugin(Some(RunPlugin {
                    path: "status-bar".into(),
                    _allow_exec_host_cmd: false,
                }))),
            },
        ],
        split_size: None,
        run: None,
    };
    assert_eq!(merged_layout, tab_layout.into());
}

Review comment (suggestion):
If you want, you could `#[derive(Default)]` on `RunPlugin` and do:

```rs
RunPlugin {
    path: "tab-bar".into(),
    ..Default::default()
}
```
I get the feeling that the `RunPlugin` struct will be growing and this should prevent us from needing to update this file every time that happens.

Code after:
    let layout = LayoutFromYaml::new(&path);
    let layout_template = layout.as_ref().unwrap();
    assert_eq!(layout_template.tabs.len(), 1);
}

#[test]
fn default_layout_merged_correctly() {
    let path = default_layout_dir("default.yaml".into());
    let layout_from_yaml = LayoutFromYaml::new(&path);
    let layout_template = layout_from_yaml.as_ref().unwrap();
    let tab_layout = layout_template
        .template
        .clone()
        .insert_tab_layout(Some(layout_template.tabs[0].clone()));
    let merged_layout = Layout {
        direction: Direction::Horizontal,
        borderless: false,
        parts: vec![
            Layout {
                direction: Direction::Vertical,
                borderless: true,
                parts: vec![],
                split_size: Some(SplitSize::Fixed(1)),
                run: Some(Run::Plugin(Some(RunPlugin {
                    path: "tab-bar".into(),
                    ..Default::default()
                }))),
            },
            Layout {
                direction: Direction::Vertical,
                borderless: false,
                parts: vec![],
                split_size: None,
                run: None,
            },
            Layout {
                direction: Direction::Vertical,
                borderless: true,
                parts: vec![],
                split_size: Some(SplitSize::Fixed(2)),
                run: Some(Run::Plugin(Some(RunPlugin {
                    path: "status-bar".into(),
                    ..Default::default()
                }))),
            },
        ],
        split_size: None,
        run: None,
    };
    assert_eq!(merged_layout, tab_layout.into());
}