@@ -728,15 +728,16 @@ def test_shell_plus(
728
728
(['convert' , '.' ]),
729
729
(['convert' , '.tmuxp.yaml' ]),
730
730
(['convert' , '.tmuxp.yaml' , '-y' ]),
731
+ (['convert' , '.tmuxp.yml' ]),
732
+ (['convert' , '.tmuxp.yml' , '-y' ]),
731
733
],
732
734
)
733
735
def test_convert (cli_args , tmpdir , monkeypatch ):
734
736
# create dummy tmuxp yaml so we don't get yelled at
735
- tmpdir .join ('.tmuxp.yaml' ).write (
736
- """
737
- session_name: hello
738
- """
739
- )
737
+ filename = '.tmuxp.yaml' if cli_args [1 ] == '.' else cli_args [1 ]
738
+ file_ext = filename .rsplit ('.' , 1 )[- 1 ]
739
+ assert file_ext in ['yaml' , 'yml' ], file_ext
740
+ tmpdir .join (filename ).write ('\n session_name: hello\n ' )
740
741
tmpdir .join ('.oh-my-zsh' ).ensure (dir = True )
741
742
monkeypatch .setenv ('HOME' , str (tmpdir ))
742
743
@@ -753,6 +754,31 @@ def test_convert(cli_args, tmpdir, monkeypatch):
753
754
)
754
755
755
756
757
+ @pytest .mark .parametrize (
758
+ "cli_args" ,
759
+ [
760
+ (['convert' , '.' ]),
761
+ (['convert' , '.tmuxp.json' ]),
762
+ (['convert' , '.tmuxp.json' , '-y' ]),
763
+ ],
764
+ )
765
+ def test_convert_json (cli_args , tmpdir , monkeypatch ):
766
+ # create dummy tmuxp yaml so we don't get yelled at
767
+ tmpdir .join ('.tmuxp.json' ).write ('{"session_name": "hello"}' )
768
+ tmpdir .join ('.oh-my-zsh' ).ensure (dir = True )
769
+ monkeypatch .setenv ('HOME' , str (tmpdir ))
770
+
771
+ with tmpdir .as_cwd ():
772
+ runner = CliRunner ()
773
+
774
+ # If autoconfirm (-y) no need to prompt y
775
+ input_args = 'y\n y\n ' if '-y' not in cli_args else ''
776
+
777
+ runner .invoke (cli .cli , cli_args , input = input_args )
778
+ assert tmpdir .join ('.tmuxp.yaml' ).check ()
779
+ assert tmpdir .join ('.tmuxp.yaml' ).open ().read () == 'session_name: hello\n '
780
+
781
+
756
782
@pytest .mark .parametrize ("cli_args" , [(['import' ])])
757
783
def test_import (cli_args , monkeypatch ):
758
784
runner = CliRunner ()
0 commit comments