On Fri, Nov 5, 2021 at 11:24 PM Amit Saha wrote:
>
>
>
> On Fri, 5 Nov 2021, 11:08 pm Axel Wagner,
> wrote:
>>
>> First, to point out the obvious: It is a bad idea to have a test read from
>> stdin. You should pass a separate io.Reader and use that.
>>
>> Next: exec.Cmd.{Stdin,Stdout,Stderr} ar
On Fri, 5 Nov 2021, 11:08 pm Axel Wagner,
wrote:
> First, to point out the obvious: It is a bad idea to have a test read from
> stdin. You should pass a separate io.Reader and use that.
>
> Next: exec.Cmd.{Stdin,Stdout,Stderr} are all set to os.DevNull by default,
> meaning you don't get any inpu
First, to point out the obvious: It is a bad idea to have a test read from
stdin. You should pass a separate io.Reader and use that.
Next: exec.Cmd.{Stdin,Stdout,Stderr} are all set to os.DevNull by default,
meaning you don't get any input or output. I assume
- `go test` does not modify Cmd.Stdin
> On 5 Nov 2021, at 10:27 pm, Amit Saha wrote:
>
> I have this test function:
>
> package main
>
> import (
> "bufio"
> "fmt"
> "os"
> "testing"
> )
>
> func TestInput(t *testing.T) {
> scanner := bufio.NewScanner(os.Stdin)
> msg := "Your name
I have this test function:
package main
import (
"bufio"
"fmt"
"os"
"testing"
)
func TestInput(t *testing.T) {
scanner := bufio.NewScanner(os.Stdin)
msg := "Your name please? Press the Enter key when done"
fmt.Fprintln(os.Stdout, msg)