Skip to content

Commit 939feaf

Browse files
committed
improve code quality
1 parent a977c7f commit 939feaf

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

channel_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/kamilsk/retry"
8+
. "github.com/kamilsk/retry"
99
)
1010

1111
func TestMultiplex(t *testing.T) {
1212
sleep := 100 * time.Millisecond
1313

1414
start := time.Now()
15-
<-retry.Multiplex(retry.WithSignal(os.Interrupt), retry.WithTimeout(sleep))
15+
<-Multiplex(WithSignal(os.Interrupt), WithTimeout(sleep))
1616
end := time.Now()
1717

1818
if expected, obtained := sleep, end.Sub(start); expected > obtained {
@@ -21,7 +21,7 @@ func TestMultiplex(t *testing.T) {
2121
}
2222

2323
func TestMultiplex_WithoutChannels(t *testing.T) {
24-
<-retry.Multiplex()
24+
<-Multiplex()
2525
}
2626

2727
func TestWithDeadline(t *testing.T) {
@@ -34,7 +34,7 @@ func TestWithDeadline(t *testing.T) {
3434
}
3535
for _, test := range tests {
3636
start := time.Now()
37-
<-retry.WithDeadline(start.Add(test.deadline))
37+
<-WithDeadline(start.Add(test.deadline))
3838
end := time.Now()
3939

4040
if !end.After(start.Add(test.deadline)) {
@@ -44,14 +44,14 @@ func TestWithDeadline(t *testing.T) {
4444
}
4545

4646
func TestWithSignal_NilSignal(t *testing.T) {
47-
<-retry.WithSignal(nil)
47+
<-WithSignal(nil)
4848
}
4949

5050
func TestWithTimeout(t *testing.T) {
5151
sleep := 100 * time.Millisecond
5252

5353
start := time.Now()
54-
<-retry.WithTimeout(sleep)
54+
<-WithTimeout(sleep)
5555
end := time.Now()
5656

5757
if expected, obtained := sleep, end.Sub(start); expected > obtained {

cmd/retry/parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type Command struct {
3131
}
3232

3333
var (
34-
re = regexp.MustCompile(`^(\w+)(?::((?:[\w\.]+,?)+))?$`)
34+
re = regexp.MustCompile(`^(\w+)(?::((?:[\w.]+,?)+))?$`)
3535

3636
compliance map[string]struct {
3737
cursor interface{}

cmd/retry/parser_gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func init() {
5353
}
5454
usage = func(output io.Writer, md Metadata) func() {
5555
return func() {
56-
fmt.Fprintf(output, `
56+
_, _ = fmt.Fprintf(output, `
5757
Usage: %s [-timeout Timeout] [--debug] [--notify] [strategy flags] -- command
5858
5959
The strategy flags

context_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/kamilsk/retry"
10+
. "github.com/kamilsk/retry"
1111
)
1212

1313
func TestWithContext(t *testing.T) {
@@ -28,7 +28,7 @@ func TestWithContext(t *testing.T) {
2828
t.Run(test.name, func(t *testing.T) {
2929

3030
start := time.Now()
31-
<-retry.WithContext(context.TODO(), tc.deadline()).Done()
31+
<-WithContext(context.TODO(), tc.deadline()).Done()
3232
end := time.Now()
3333

3434
if !end.After(start.Add(tc.expected)) {

retry_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/kamilsk/retry/strategy"
9-
108
. "github.com/kamilsk/retry"
9+
. "github.com/kamilsk/retry/strategy"
1110
)
1211

1312
func TestRetry(t *testing.T) {
@@ -35,7 +34,7 @@ func TestRetry_PanickedAction(t *testing.T) {
3534
panic("catch me if you can")
3635
}
3736

38-
err := Retry(nil, action, strategy.Infinite())
37+
err := Retry(nil, action, Infinite())
3938

4039
if nil == err {
4140
t.Error("expected an error")
@@ -65,7 +64,7 @@ func TestRetry_RetriesUntilNoErrorReturned(t *testing.T) {
6564
return errors.New("error")
6665
}
6766

68-
err := Retry(nil, action, strategy.Infinite())
67+
err := Retry(nil, action, Infinite())
6968

7069
if nil != err {
7170
t.Error("expected a nil error")
@@ -81,7 +80,7 @@ func TestRetry_RetriesUntilNoErrorReturned(t *testing.T) {
8180
func TestRetry_RetriesWithAlreadyDoneContext(t *testing.T) {
8281
deadline, expected := WithTimeout(0), "operation timeout"
8382

84-
if err := Retry(deadline, func(uint) error { return nil }, strategy.Infinite()); !IsTimeout(err) {
83+
if err := Retry(deadline, func(uint) error { return nil }, Infinite()); !IsTimeout(err) {
8584
t.Errorf("an unexpected error. expected: %s; obtained: %v", expected, err)
8685
}
8786
}
@@ -94,7 +93,7 @@ func TestRetry_RetriesWithDeadline(t *testing.T) {
9493
return nil
9594
}
9695

97-
if err := Retry(deadline, action, strategy.Infinite()); !IsTimeout(err) {
96+
if err := Retry(deadline, action, Infinite()); !IsTimeout(err) {
9897
t.Errorf("an unexpected error. expected: %s; obtained: %v", expected, err)
9998
}
10099
}

0 commit comments

Comments
 (0)