You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
654 B

4 years ago
package command_test
import (
"bytes"
"context"
"testing"
"gitoa.ru/go-4devs/console"
"gitoa.ru/go-4devs/console/example/pkg/command"
"gitoa.ru/go-4devs/console/input"
"gitoa.ru/go-4devs/console/output"
4 years ago
)
func TestCreateUser(t *testing.T) {
ctx := context.Background()
buf := bytes.Buffer{}
out := output.Buffer(&buf)
4 years ago
in := &input.Array{}
in.SetArgument("username", "andrey")
4 years ago
err := console.Run(ctx, command.CreateUser(false), in, out)
if err != nil {
t.Fatalf("expect nil err, got :%s", err)
}
expect := "User Creator\nUsername: andrey\n"
if expect != buf.String() {
t.Errorf("expect: %s, got:%s", expect, buf.String())
}
}