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