Skip to content

Commit 1a7393b

Browse files
committed
Fix stuttering names
1 parent a5c7042 commit 1a7393b

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

console/console.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ import (
3131
// input back on it's tty. Console can also multiplex other sources of input
3232
// and multiplex its output to other writers.
3333
type Console struct {
34-
opts ConsoleOpts
34+
opts Opts
3535
pty pty.Pty
3636
runeReader *bufio.Reader
3737
closers []io.Closer
3838
}
3939

40-
// ConsoleOpt allows setting Console options.
41-
type ConsoleOpt func(*ConsoleOpts) error
40+
// Opt allows setting Console options.
41+
type Opt func(*Opts) error
4242

43-
// ConsoleOpts provides additional options on creating a Console.
44-
type ConsoleOpts struct {
43+
// Opts provides additional options on creating a Console.
44+
type Opts struct {
4545
Logger *log.Logger
4646
Stdouts []io.Writer
4747
ExpectObservers []Observer
@@ -62,33 +62,33 @@ type Observer func(matchers []Matcher, buf string, err error)
6262
// last writer, writing to it's internal buffer for matching expects.
6363
// If a listed writer returns an error, that overall write operation stops and
6464
// returns the error; it does not continue down the list.
65-
func WithStdout(writers ...io.Writer) ConsoleOpt {
66-
return func(opts *ConsoleOpts) error {
65+
func WithStdout(writers ...io.Writer) Opt {
66+
return func(opts *Opts) error {
6767
opts.Stdouts = append(opts.Stdouts, writers...)
6868
return nil
6969
}
7070
}
7171

7272
// WithLogger adds a logger for Console to log debugging information to. By
7373
// default Console will discard logs.
74-
func WithLogger(logger *log.Logger) ConsoleOpt {
75-
return func(opts *ConsoleOpts) error {
74+
func WithLogger(logger *log.Logger) Opt {
75+
return func(opts *Opts) error {
7676
opts.Logger = logger
7777
return nil
7878
}
7979
}
8080

8181
// WithExpectObserver adds an ExpectObserver to allow monitoring Expect operations.
82-
func WithExpectObserver(observers ...Observer) ConsoleOpt {
83-
return func(opts *ConsoleOpts) error {
82+
func WithExpectObserver(observers ...Observer) Opt {
83+
return func(opts *Opts) error {
8484
opts.ExpectObservers = append(opts.ExpectObservers, observers...)
8585
return nil
8686
}
8787
}
8888

8989
// NewConsole returns a new Console with the given options.
90-
func NewConsole(opts ...ConsoleOpt) (*Console, error) {
91-
options := ConsoleOpts{
90+
func NewConsole(opts ...Opt) (*Console, error) {
91+
options := Opts{
9292
Logger: log.New(ioutil.Discard, "", 0),
9393
}
9494

console/expect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func (c *Console) ExpectString(s string) (string, error) {
4040
// expecting input yet, it will be blocked. Sends are queued up in tty's
4141
// internal buffer so that the next Expect will read the remaining bytes (i.e.
4242
// rest of prompt) as well as its conditions.
43-
func (c *Console) Expect(opts ...Opt) (string, error) {
44-
var options Opts
43+
func (c *Console) Expect(opts ...ExpectOpt) (string, error) {
44+
var options ExpectOpts
4545
for _, opt := range opts {
4646
if err := opt(&options); err != nil {
4747
return "", err

console/expect_opt.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ import (
2020
"time"
2121
)
2222

23-
// Opt allows settings Expect options.
24-
type Opt func(*Opts) error
23+
// ExpectOpt allows settings Expect options.
24+
type ExpectOpt func(*ExpectOpts) error
2525

26-
// ConsoleCallback is a callback function to execute if a match is found for
26+
// Callback is a callback function to execute if a match is found for
2727
// the chained matcher.
28-
type ConsoleCallback func(buf *bytes.Buffer) error
28+
type Callback func(buf *bytes.Buffer) error
2929

30-
// Opts provides additional options on Expect.
31-
type Opts struct {
30+
// ExpectOpts provides additional options on Expect.
31+
type ExpectOpts struct {
3232
Matchers []Matcher
3333
ReadTimeout *time.Duration
3434
}
3535

3636
// Match sequentially calls Match on all matchers in ExpectOpts and returns the
3737
// first matcher if a match exists, otherwise nil.
38-
func (eo Opts) Match(v interface{}) Matcher {
38+
func (eo ExpectOpts) Match(v interface{}) Matcher {
3939
for _, matcher := range eo.Matchers {
4040
if matcher.Match(v) {
4141
return matcher
@@ -83,7 +83,7 @@ func (sm *stringMatcher) Criteria() interface{} {
8383
// allMatcher fulfills the Matcher interface to match a group of ExpectOpt
8484
// against any value.
8585
type allMatcher struct {
86-
options Opts
86+
options ExpectOpts
8787
}
8888

8989
func (am *allMatcher) Match(v interface{}) bool {
@@ -109,9 +109,9 @@ func (am *allMatcher) Criteria() interface{} {
109109

110110
// All adds an Expect condition to exit if the content read from Console's tty
111111
// matches all of the provided ExpectOpt, in any order.
112-
func All(expectOpts ...Opt) Opt {
113-
return func(opts *Opts) error {
114-
var options Opts
112+
func All(expectOpts ...ExpectOpt) ExpectOpt {
113+
return func(opts *ExpectOpts) error {
114+
var options ExpectOpts
115115
for _, opt := range expectOpts {
116116
if err := opt(&options); err != nil {
117117
return err
@@ -127,8 +127,8 @@ func All(expectOpts ...Opt) Opt {
127127

128128
// String adds an Expect condition to exit if the content read from Console's
129129
// tty contains any of the given strings.
130-
func String(strs ...string) Opt {
131-
return func(opts *Opts) error {
130+
func String(strs ...string) ExpectOpt {
131+
return func(opts *ExpectOpts) error {
132132
for _, str := range strs {
133133
opts.Matchers = append(opts.Matchers, &stringMatcher{
134134
str: str,

console/expect_opt_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestExpectOptString(t *testing.T) {
2828

2929
tests := []struct {
3030
title string
31-
opt Opt
31+
opt ExpectOpt
3232
data string
3333
expected bool
3434
}{
@@ -63,7 +63,7 @@ func TestExpectOptString(t *testing.T) {
6363
t.Run(test.title, func(t *testing.T) {
6464
t.Parallel()
6565

66-
var options Opts
66+
var options ExpectOpts
6767
err := test.opt(&options)
6868
require.Nil(t, err)
6969

@@ -86,7 +86,7 @@ func TestExpectOptAll(t *testing.T) {
8686

8787
tests := []struct {
8888
title string
89-
opt Opt
89+
opt ExpectOpt
9090
data string
9191
expected bool
9292
}{
@@ -144,7 +144,7 @@ func TestExpectOptAll(t *testing.T) {
144144
test := test
145145
t.Run(test.title, func(t *testing.T) {
146146
t.Parallel()
147-
var options Opts
147+
var options ExpectOpts
148148
err := test.opt(&options)
149149
require.Nil(t, err)
150150

console/expect_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ func Prompt(in io.Reader, out io.Writer) error {
7171
return nil
7272
}
7373

74-
func newTestConsole(t *testing.T, opts ...ConsoleOpt) (*Console, error) {
75-
opts = append([]ConsoleOpt{
74+
func newTestConsole(t *testing.T, opts ...Opt) (*Console, error) {
75+
opts = append([]Opt{
7676
expectNoError(t),
7777
}, opts...)
7878
return NewConsole(opts...)
7979
}
8080

81-
func expectNoError(t *testing.T) ConsoleOpt {
81+
func expectNoError(t *testing.T) Opt {
8282
return WithExpectObserver(
8383
func(matchers []Matcher, buf string, err error) {
8484
if err == nil {

0 commit comments

Comments
 (0)