aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/input/unit
diff options
context:
space:
mode:
authorCory Forsstrom <cforsstrom18@gmail.com>2023-03-01 07:11:16 -0800
committerGitHub <noreply@github.com>2023-03-01 16:11:16 +0100
commit6e6e2691a8b8435ac7a8535cf0c4e0645ec20fa2 (patch)
tree56bf1dec9ea1eb4dfd89b07ee70b2e2f5435522b /zellij-utils/src/input/unit
parentdocs(changelog): various fixes (diff)
downloadsl0ppij-6e6e2691a8b8435ac7a8535cf0c4e0645ec20fa2.tar.gz
sl0ppij-6e6e2691a8b8435ac7a8535cf0c4e0645ec20fa2.tar.xz
sl0ppij-6e6e2691a8b8435ac7a8535cf0c4e0645ec20fa2.zip
fix(plugins): location path decoding from Url (#2190)
* Add unit test for plugin run location parsing * Fix file plugin parsing for relative paths * Update test to check for path with spaces * Add a couple more tests
Diffstat (limited to 'zellij-utils/src/input/unit')
-rw-r--r--zellij-utils/src/input/unit/layout_test.rs88
1 files changed, 88 insertions, 0 deletions
diff --git a/zellij-utils/src/input/unit/layout_test.rs b/zellij-utils/src/input/unit/layout_test.rs
index 670273b0..c8c6c64d 100644
--- a/zellij-utils/src/input/unit/layout_test.rs
+++ b/zellij-utils/src/input/unit/layout_test.rs
@@ -1942,3 +1942,91 @@ fn cannot_define_stacked_panes_with_grandchildren_in_pane_template() {
let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None, None);
assert!(layout.is_err(), "error provided for tab name with space");
}
+
+fn run_plugin_location_parsing() {
+ let kdl_layout = r#"
+ layout {
+ pane {
+ plugin location="zellij:tab-bar"
+ }
+ pane {
+ plugin location="file:/path/to/my/plugin.wasm"
+ }
+ pane {
+ plugin location="file:plugin.wasm"
+ }
+ pane {
+ plugin location="file:relative/with space/plugin.wasm"
+ }
+ pane {
+ plugin location="file:///absolute/with space/plugin.wasm"
+ }
+ pane {
+ plugin location="file:c:/absolute/windows/plugin.wasm"
+ }
+ }
+ "#;
+ let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None, None).unwrap();
+ let expected_layout = Layout {
+ template: Some((
+ TiledPaneLayout {
+ children: vec![
+ TiledPaneLayout {
+ run: Some(Run::Plugin(RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: RunPluginLocation::Zellij(PluginTag::new("tab-bar")),
+ })),
+ ..Default::default()
+ },
+ TiledPaneLayout {
+ run: Some(Run::Plugin(RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: RunPluginLocation::File(PathBuf::from(
+ "/path/to/my/plugin.wasm",
+ )),
+ })),
+ ..Default::default()
+ },
+ TiledPaneLayout {
+ run: Some(Run::Plugin(RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: RunPluginLocation::File(PathBuf::from("plugin.wasm")),
+ })),
+ ..Default::default()
+ },
+ TiledPaneLayout {
+ run: Some(Run::Plugin(RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: RunPluginLocation::File(PathBuf::from(
+ "relative/with space/plugin.wasm",
+ )),
+ })),
+ ..Default::default()
+ },
+ TiledPaneLayout {
+ run: Some(Run::Plugin(RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: RunPluginLocation::File(PathBuf::from(
+ "/absolute/with space/plugin.wasm",
+ )),
+ })),
+ ..Default::default()
+ },
+ TiledPaneLayout {
+ run: Some(Run::Plugin(RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: RunPluginLocation::File(PathBuf::from(
+ "c:/absolute/windows/plugin.wasm",
+ )),
+ })),
+ ..Default::default()
+ },
+ ],
+ ..Default::default()
+ },
+ vec![],
+ )),
+ ..Default::default()
+ };
+ assert_eq!(layout, expected_layout);
+}