@@ -402,6 +402,20 @@ def test_resolve_workdir_fallback_project_name():
402402 assert opener .resolve_workdir ({}, "proj" ) == "/work/proj"
403403
404404
405+ def test_resolve_workspace_none_when_unset ():
406+ assert opener .resolve_workspace ({}) is None
407+
408+
409+ def test_resolve_workspace_blank_is_none ():
410+ assert opener .resolve_workspace ({"DEVBASE_WORKSPACE" : " " }) is None
411+
412+
413+ def test_resolve_workspace_returns_path ():
414+ env = {"DEVBASE_WORKSPACE" : "/home/ubuntu/share/work/uttarov2-doc.workspace" }
415+ assert opener .resolve_workspace (env ) == \
416+ "/home/ubuntu/share/work/uttarov2-doc.workspace"
417+
418+
405419# ---------------------------------------------------------------------------
406420# decide_action (§2.4 マトリクス全分岐)
407421# ---------------------------------------------------------------------------
@@ -472,6 +486,43 @@ def test_open_editor_launch_invokes_launcher(monkeypatch):
472486 assert cmd [2 ].endswith ("/work/carmo" )
473487
474488
489+ def test_open_editor_launch_uses_file_uri_for_workspace (monkeypatch ):
490+ """DEVBASE_WORKSPACE 指定時は --file-uri でワークスペースファイルを開く。"""
491+ monkeypatch .setattr (opener .shutil , "which" , lambda c : "/usr/bin/code" )
492+ calls = []
493+ result = opener .open_editor (
494+ project_name = "uttarov2-doc" , dev_service_name = "dev" ,
495+ workdir = "/work/uttarov2-doc" ,
496+ environ = {"DEVBASE_WORKSPACE" :
497+ "/home/ubuntu/share/work/uttarov2-doc.workspace" },
498+ isatty = True , launcher = lambda cmd , env : calls .append (cmd ),
499+ )
500+ assert result == "launch"
501+ cmd = calls [0 ]
502+ assert cmd [1 ] == "--file-uri"
503+ assert cmd [2 ].startswith ("vscode-remote://attached-container+" )
504+ assert cmd [2 ].endswith ("/home/ubuntu/share/work/uttarov2-doc.workspace" )
505+
506+
507+ def test_open_editor_print_command_file_uri_for_workspace (monkeypatch , caplog ):
508+ """plain SSH の提示コマンドも DEVBASE_WORKSPACE 指定時は --file-uri になる。"""
509+ import logging
510+ monkeypatch .setattr (opener .shutil , "which" , lambda c : "/usr/bin/code" )
511+ with caplog .at_level (logging .INFO ):
512+ result = opener .open_editor (
513+ project_name = "uttarov2-doc" , dev_service_name = "dev" ,
514+ workdir = "/work/uttarov2-doc" ,
515+ environ = {"SSH_CONNECTION" : "1.2.3.4 5 6.7.8.9 22" ,
516+ "DEVBASE_WORKSPACE" :
517+ "/home/ubuntu/share/work/uttarov2-doc.workspace" },
518+ isatty = True , launcher = lambda cmd , env : None ,
519+ )
520+ assert result == "print_command"
521+ text = "\n " .join (r .getMessage () for r in caplog .records )
522+ assert "code --file-uri" in text
523+ assert "uttarov2-doc.workspace" in text
524+
525+
475526def test_open_editor_launch_nested_uri_under_remote_ssh (monkeypatch ):
476527 """Remote-SSH (in_vscode + ssh) かつ DEVBASE_EDITOR_SSH_HOST 設定時はネスト URI で launch。"""
477528 monkeypatch .setattr (opener .shutil , "which" , lambda c : "/usr/bin/code" )
0 commit comments