bpoole16 commented on a change in pull request #2520: Prints 
bashauto-completion install script to STDOUT
URL: 
https://github.com/apache/incubator-openwhisk/pull/2520#discussion_r131166015
 
 

 ##########
 File path: tests/src/test/scala/system/basic/WskSdkTests.scala
 ##########
 @@ -89,23 +90,40 @@ class WskSdkTests
         FileUtils.deleteDirectory(dir)
     }
 
-    it should "install the bash auto-completion bash script" in {
-        // Use a temp dir for testing to not disturb user's local folder
+    it should "print bash command completion script to STDOUT" in {
+        val auth: Seq[String] = Seq("--auth", wskprops.authKey)
+        val msg = "bash completion for wsk"    // Subject to change, dependent 
on Cobra script
+
+        val stdout = wsk.cli(Seq("sdk", "install", "bashauto") ++ 
wskprops.overrides ++ auth, expectedExitCode = SUCCESS_EXIT).stdout
+        stdout should include(msg)
+    }
+
+    it should "check if .bashrc exists and append it with the bash auto 
completion command when using --bashrc" in {
+        val auth: Seq[String] = Seq("--auth", wskprops.authKey)
+        val homeDir = System.getProperty("user.home")
+        val bashrc = new File(homeDir, ".bashrc")
         val dir = File.createTempFile("wskinstall", ".tmp")
         dir.delete()
         dir.mkdir() should be(true)
 
-        val scriptfilename = "wsk_cli_bash_completion.sh"
-        var scriptfile = new File(dir.getPath(), scriptfilename)
+        val backUp = File.createTempFile("backup",".tmp", dir)
+        backUp.exists() should be(true)
+
         try {
-            val stdout = wsk.cli(Seq("sdk", "install", "bashauto"), workingDir 
= dir, expectedExitCode = SUCCESS_EXIT).stdout
-            stdout should include("is installed in the current directory")
-            val fileContent = FileUtils.readFileToString(scriptfile)
-            fileContent should include("bash completion for wsk")
+            if (bashrc.exists()) {
+                println("Found bashrc")
+                FileUtils.copyFile(bashrc, backUp)
+                val stdout = wsk.cli(Seq("sdk", "install", "bashauto", 
"--bashrc") ++ wskprops.overrides ++ auth, expectedExitCode = 
SUCCESS_EXIT).stdout
+                val fileOutput = FileUtils.readLines(bashrc)
+                stdout should include("bash completion for wsk" )    // 
Subject to change, dependent on Cobra script
 
 Review comment:
   I should clarify, `--bashrc` paired with eval will append the bashrc and run 
the script. If you just run `wsk sdk install bashauto --bashrc` it will just 
append the bashrc. But anything the `wsk sdk install bashauto` (even with the 
flag) is used it prints to stdout. 
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to