@@ -601,7 +601,7 @@ func (s *RSuite) TestRenvEnvironmentErrorCheck_renvNotInstalled() {
601
601
602
602
executor := executortest .NewMockExecutor ()
603
603
executor .On ("RunCommand" , mock .Anything , []string {"--version" }, mock .Anything , mock .Anything ).Return ([]byte ("R version 4.3.0 (2023-04-21)" ), nil , nil )
604
- executor .On ("RunCommand" , "/usr/bin/R" , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("" ), nil , nil )
604
+ executor .On ("RunCommand" , mock . Anything , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("" ), nil , nil )
605
605
606
606
i , _ := NewRInterpreter (s .cwd , util.Path {}, log , executor , nil , nil )
607
607
interpreter := i .(* defaultRInterpreter )
@@ -613,11 +613,10 @@ func (s *RSuite) TestRenvEnvironmentErrorCheck_renvNotInstalled() {
613
613
s .Error (err )
614
614
s .Equal (err .GetCode (), types .ErrorRenvPackageNotInstalled )
615
615
s .Equal (err .Message , "Package renv is not installed. An renv lockfile is needed for deployment." )
616
- s .Equal (err .Data , types.ErrorData {
617
- "Action" : "renvsetup" ,
618
- "ActionLabel" : "Setup renv" ,
619
- "Command" : "/usr/bin/R -s -e \" install.packages(\\ \" renv\\ \" ); renv::init();\" " ,
620
- })
616
+ s .Equal (err .Data ["Action" ], "renvsetup" )
617
+ s .Equal (err .Data ["ActionLabel" ], "Setup renv" )
618
+ s .Contains (err .Data ["Command" ], "install.packages" )
619
+ s .Contains (err .Data ["Command" ], "renv::init()" )
621
620
}
622
621
623
622
func (s * RSuite ) TestRenvEnvironmentErrorCheck_renvInstallCheckErr () {
@@ -626,7 +625,7 @@ func (s *RSuite) TestRenvEnvironmentErrorCheck_renvInstallCheckErr() {
626
625
renvCmdErr := errors .New ("renv command errrz" )
627
626
executor := executortest .NewMockExecutor ()
628
627
executor .On ("RunCommand" , mock .Anything , []string {"--version" }, mock .Anything , mock .Anything ).Return ([]byte ("R version 4.3.0 (2023-04-21)" ), nil , nil )
629
- executor .On ("RunCommand" , "/usr/bin/R" , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("" ), nil , renvCmdErr )
628
+ executor .On ("RunCommand" , mock . Anything , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("" ), nil , renvCmdErr )
630
629
631
630
i , _ := NewRInterpreter (s .cwd , util.Path {}, log , executor , nil , nil )
632
631
interpreter := i .(* defaultRInterpreter )
@@ -647,8 +646,8 @@ func (s *RSuite) TestRenvEnvironmentErrorCheck_renvRequiresInit() {
647
646
renvStatusOutput := []byte ("Use `renv::init()` to initialize the project." )
648
647
executor := executortest .NewMockExecutor ()
649
648
executor .On ("RunCommand" , mock .Anything , []string {"--version" }, mock .Anything , mock .Anything ).Return ([]byte ("R version 4.3.0 (2023-04-21)" ), nil , nil )
650
- executor .On ("RunCommand" , "/usr/bin/R" , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("/usr/dir/lib/R/x86_64/4.4/library/renv" ), nil , nil )
651
- executor .On ("RunCommand" , "/usr/bin/R" , []string {"-s" , "-e" , "renv::status()" }, mock .Anything , mock .Anything ).Return (renvStatusOutput , nil , nil )
649
+ executor .On ("RunCommand" , mock . Anything , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("/usr/dir/lib/R/x86_64/4.4/library/renv" ), nil , nil )
650
+ executor .On ("RunCommand" , mock . Anything , []string {"-s" , "-e" , "renv::status()" }, mock .Anything , mock .Anything ).Return (renvStatusOutput , nil , nil )
652
651
653
652
i , _ := NewRInterpreter (s .cwd , util.Path {}, log , executor , nil , nil )
654
653
interpreter := i .(* defaultRInterpreter )
@@ -660,11 +659,9 @@ func (s *RSuite) TestRenvEnvironmentErrorCheck_renvRequiresInit() {
660
659
s .Error (err )
661
660
s .Equal (err .GetCode (), types .ErrorRenvActionRequired )
662
661
s .Equal (err .Message , `Project requires renv initialization "renv::init()" to be deployed.` )
663
- s .Equal (err .Data , types.ErrorData {
664
- "Action" : "renvinit" ,
665
- "ActionLabel" : "Setup renv" ,
666
- "Command" : "/usr/bin/R -s -e \" renv::init()\" " ,
667
- })
662
+ s .Equal (err .Data ["Action" ], "renvinit" )
663
+ s .Equal (err .Data ["ActionLabel" ], "Setup renv" )
664
+ s .Contains (err .Data ["Command" ], "renv::init()" )
668
665
}
669
666
670
667
func (s * RSuite ) TestRenvEnvironmentErrorCheck_lockfileMissing () {
@@ -673,8 +670,8 @@ func (s *RSuite) TestRenvEnvironmentErrorCheck_lockfileMissing() {
673
670
renvStatusOutput := []byte ("Use `renv::snapshot()` to create a lockfile." )
674
671
executor := executortest .NewMockExecutor ()
675
672
executor .On ("RunCommand" , mock .Anything , []string {"--version" }, mock .Anything , mock .Anything ).Return ([]byte ("R version 4.3.0 (2023-04-21)" ), nil , nil )
676
- executor .On ("RunCommand" , "/usr/bin/R" , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("/usr/dir/lib/R/x86_64/4.4/library/renv" ), nil , nil )
677
- executor .On ("RunCommand" , "/usr/bin/R" , []string {"-s" , "-e" , "renv::status()" }, mock .Anything , mock .Anything ).Return (renvStatusOutput , nil , nil )
673
+ executor .On ("RunCommand" , mock . Anything , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("/usr/dir/lib/R/x86_64/4.4/library/renv" ), nil , nil )
674
+ executor .On ("RunCommand" , mock . Anything , []string {"-s" , "-e" , "renv::status()" }, mock .Anything , mock .Anything ).Return (renvStatusOutput , nil , nil )
678
675
679
676
i , _ := NewRInterpreter (s .cwd , util.Path {}, log , executor , nil , nil )
680
677
interpreter := i .(* defaultRInterpreter )
@@ -686,11 +683,9 @@ func (s *RSuite) TestRenvEnvironmentErrorCheck_lockfileMissing() {
686
683
s .Error (err )
687
684
s .Equal (err .GetCode (), types .ErrorRenvActionRequired )
688
685
s .Equal (err .Message , `Project requires renv to update the lockfile to be deployed.` )
689
- s .Equal (err .Data , types.ErrorData {
690
- "Action" : "renvsnapshot" ,
691
- "ActionLabel" : "Setup lockfile" ,
692
- "Command" : "/usr/bin/R -s -e \" renv::snapshot()\" " ,
693
- })
686
+ s .Equal (err .Data ["Action" ], "renvsnapshot" )
687
+ s .Equal (err .Data ["ActionLabel" ], "Setup lockfile" )
688
+ s .Contains (err .Data ["Command" ], "renv::snapshot()" )
694
689
}
695
690
696
691
func (s * RSuite ) TestRenvEnvironmentErrorCheck_unknownRenvStatus () {
@@ -699,8 +694,8 @@ func (s *RSuite) TestRenvEnvironmentErrorCheck_unknownRenvStatus() {
699
694
renvStatusOutput := []byte ("- The project is out-of-sync -- use `renv::status()` for details." )
700
695
executor := executortest .NewMockExecutor ()
701
696
executor .On ("RunCommand" , mock .Anything , []string {"--version" }, mock .Anything , mock .Anything ).Return ([]byte ("R version 4.3.0 (2023-04-21)" ), nil , nil )
702
- executor .On ("RunCommand" , "/usr/bin/R" , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("/usr/dir/lib/R/x86_64/4.4/library/renv" ), nil , nil )
703
- executor .On ("RunCommand" , "/usr/bin/R" , []string {"-s" , "-e" , "renv::status()" }, mock .Anything , mock .Anything ).Return (renvStatusOutput , nil , nil )
697
+ executor .On ("RunCommand" , mock . Anything , []string {"-s" , "-e" , "cat(system.file(package = \" renv\" ))" }, mock .Anything , mock .Anything ).Return ([]byte ("/usr/dir/lib/R/x86_64/4.4/library/renv" ), nil , nil )
698
+ executor .On ("RunCommand" , mock . Anything , []string {"-s" , "-e" , "renv::status()" }, mock .Anything , mock .Anything ).Return (renvStatusOutput , nil , nil )
704
699
705
700
i , _ := NewRInterpreter (s .cwd , util.Path {}, log , executor , nil , nil )
706
701
interpreter := i .(* defaultRInterpreter )
@@ -712,9 +707,7 @@ func (s *RSuite) TestRenvEnvironmentErrorCheck_unknownRenvStatus() {
712
707
s .Error (err )
713
708
s .Equal (err .GetCode (), types .ErrorRenvActionRequired )
714
709
s .Equal (err .Message , `The renv environment for this project is not in a healthy state. Run renv::status() for more details.` )
715
- s .Equal (err .Data , types.ErrorData {
716
- "Action" : "renvstatus" ,
717
- "ActionLabel" : "Run and show renv::status()" ,
718
- "Command" : "/usr/bin/R -s -e \" renv::status()\" " ,
719
- })
710
+ s .Equal (err .Data ["Action" ], "renvstatus" )
711
+ s .Equal (err .Data ["ActionLabel" ], "Run and show renv::status()" )
712
+ s .Contains (err .Data ["Command" ], "renv::status()" )
720
713
}
0 commit comments