{"comment":{"url":"https://api.github.com/repos/ibmjstart/cf-download/comments/10614339","html_url":"https://github.com/ibmjstart/cf-download/commit/838acb990dfaa293bc5452e6f4c6042260e00a74#commitcomment-10614339","id":10614339,"user":{"login":"simonleung8","id":5448247,"avatar_url":"https://avatars.githubusercontent.com/u/5448247?v=3","gravatar_id":"","url":"https://api.github.com/users/simonleung8","html_url":"https://github.com/simonleung8","followers_url":"https://api.github.com/users/simonleung8/followers","following_url":"https://api.github.com/users/simonleung8/following{/other_user}","gists_url":"https://api.github.com/users/simonleung8/gists{/gist_id}","starred_url":"https://api.github.com/users/simonleung8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonleung8/subscriptions","organizations_url":"https://api.github.com/users/simonleung8/orgs","repos_url":"https://api.github.com/users/simonleung8/repos","events_url":"https://api.github.com/users/simonleung8/events{/privacy}","received_events_url":"https://api.github.com/users/simonleung8/received_events","type":"User","site_admin":false},"position":null,"line":null,"path":"","commit_id":"838acb990dfaa293bc5452e6f4c6042260e00a74","created_at":"2015-04-08T00:13:02Z","updated_at":"2015-04-08T00:13:02Z","body":"A lot of error checks are not covered by tests. We can test it by asserting the terminal output to contain the text we are expecting. To do this, we want to capture what is being printed to os.Stdout, which is just a *os.File, and could be redirect to a file. For example.\r\n```Go\r\noutput, err := ioutil.TempFile(\"\", \"\")\r\nΩ(err).ToNot(HaveOccurred())\r\n\r\nold := os.Stdout\r\nos.Stdout = output\r\n\r\nwg.Add(1)\r\ngo d.Download(files, dirs, readPath, writePath, filterList)\r\nwg.Wait()\r\n\r\nreadFile.Close()\r\nos.Stdout = old\r\n\t\t\t\t\r\nb, _ := ioutil.ReadFile(readFile.Name())\r\n```\r\nnow you have the output from `d.Download` in the []byte `b`. You can see the content with `fmt.Println(string(b))`\r\n\r\nor do an assertion, for example, Expect(strings.Contains(string(b), \"ERROR\")).ToNot(BeTrue())"}}