Skip to content

Commit c0dc9ce

Browse files
author
Dmitriy Kalinin
committed
switch to plain test framework
1 parent 623191f commit c0dc9ce

File tree

324 files changed

+19946
-191822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+19946
-191822
lines changed

go.mod

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@ go 1.17
55
require (
66
github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835
77
github.com/mattn/go-isatty v0.0.11
8-
github.com/onsi/ginkgo v1.13.0
9-
github.com/onsi/gomega v1.10.1
8+
github.com/stretchr/testify v1.7.1
109
github.com/vito/go-interact v1.0.1
1110
gopkg.in/yaml.v2 v2.3.0
1211
)
1312

1413
require (
15-
github.com/fsnotify/fsnotify v1.4.9 // indirect
14+
github.com/davecgh/go-spew v1.1.0 // indirect
1615
github.com/mattn/go-colorable v0.1.4 // indirect
17-
github.com/nxadm/tail v1.4.4 // indirect
18-
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 // indirect
16+
github.com/pmezard/go-difflib v1.0.0 // indirect
1917
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
2018
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
21-
golang.org/x/text v0.3.2 // indirect
22-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
23-
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
19+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
2420
)

go.sum

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835 h1:mYQweUIBD+TB
22
github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835/go.mod h1:dYeVsKp1vvK8XjdTPR1gF+uk+9doxKeO3hqQTOCr7T4=
33
github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A=
44
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
5+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
6+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
57
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
68
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
79
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
@@ -11,7 +13,6 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x
1113
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
1214
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
1315
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
14-
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
1516
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
1617
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
1718
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@@ -33,7 +34,12 @@ github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1ls
3334
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
3435
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
3536
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
37+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
38+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3639
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
40+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
41+
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
42+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
3743
github.com/vito/go-interact v1.0.1 h1:O8xi8c93bRUv2Tb/v6HdiuGc+WnWt+AQzF74MOOdlBs=
3844
github.com/vito/go-interact v1.0.1/go.mod h1:HrdHSJXD2yn1MhlTwSIMeFgQ5WftiIorszVGd3S/DAA=
3945
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -65,7 +71,6 @@ google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ
6571
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
6672
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
6773
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
68-
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
6974
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
7075
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
7176
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -75,3 +80,5 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
7580
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
7681
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
7782
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
83+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
84+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

ui/combo_writer_test.go

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,46 @@ package ui_test
33
import (
44
"bytes"
55
"fmt"
6-
"io"
7-
8-
. "github.com/onsi/ginkgo"
9-
. "github.com/onsi/gomega"
6+
"testing"
107

118
. "github.com/cppforlife/go-cli-ui/ui"
9+
"github.com/stretchr/testify/assert"
1210
)
1311

14-
var _ = Describe("ComboWriter", func() {
15-
var (
16-
outBuffer *bytes.Buffer
17-
errBuffer *bytes.Buffer
18-
ui UI
19-
w io.Writer
20-
)
21-
22-
BeforeEach(func() {
23-
outBuffer = bytes.NewBufferString("")
24-
errBuffer = bytes.NewBufferString("")
25-
logger := NewRecordingLogger()
26-
ui = NewWriterUI(outBuffer, errBuffer, logger)
27-
w = NewComboWriter(ui).Writer("prefix: ")
28-
})
29-
30-
Describe("Writer.Write", func() {
31-
type Example struct {
32-
Ins []string
33-
Out string
34-
}
35-
36-
examples := []Example{
37-
{Ins: []string{""}, Out: ""},
38-
{Ins: []string{"", ""}, Out: ""},
39-
{Ins: []string{"\n"}, Out: "prefix: \n"},
40-
{Ins: []string{"", "\n"}, Out: "prefix: \n"},
41-
{Ins: []string{"\n\n", "\n"}, Out: "prefix: \nprefix: \nprefix: \n"},
42-
{Ins: []string{"piece1"}, Out: "prefix: piece1"},
43-
{Ins: []string{"piece1", "piece2"}, Out: "prefix: piece1piece2"},
44-
{Ins: []string{"piece1", "piece2\n"}, Out: "prefix: piece1piece2\n"},
45-
{Ins: []string{"\npiece1", "piece2"}, Out: "prefix: \nprefix: piece1piece2"},
46-
{Ins: []string{"piece1", "\npiece2"}, Out: "prefix: piece1\nprefix: piece2"},
47-
{Ins: []string{"piece1\n", "piece2"}, Out: "prefix: piece1\nprefix: piece2"},
48-
}
49-
50-
for i, ex := range examples {
51-
ex := ex
52-
53-
It(fmt.Sprintf("prints correctly '%d'", i), func() {
54-
for _, in := range ex.Ins {
55-
w.Write([]byte(in))
56-
}
57-
Expect(outBuffer.String()).To(Equal(ex.Out))
58-
})
59-
}
60-
})
61-
})
12+
func TestComboWriter(t *testing.T) {
13+
type Example struct {
14+
Ins []string
15+
Out string
16+
}
17+
18+
examples := []Example{
19+
{Ins: []string{""}, Out: ""},
20+
{Ins: []string{"", ""}, Out: ""},
21+
{Ins: []string{"\n"}, Out: "prefix: \n"},
22+
{Ins: []string{"", "\n"}, Out: "prefix: \n"},
23+
{Ins: []string{"\n\n", "\n"}, Out: "prefix: \nprefix: \nprefix: \n"},
24+
{Ins: []string{"piece1"}, Out: "prefix: piece1"},
25+
{Ins: []string{"piece1", "piece2"}, Out: "prefix: piece1piece2"},
26+
{Ins: []string{"piece1", "piece2\n"}, Out: "prefix: piece1piece2\n"},
27+
{Ins: []string{"\npiece1", "piece2"}, Out: "prefix: \nprefix: piece1piece2"},
28+
{Ins: []string{"piece1", "\npiece2"}, Out: "prefix: piece1\nprefix: piece2"},
29+
{Ins: []string{"piece1\n", "piece2"}, Out: "prefix: piece1\nprefix: piece2"},
30+
}
31+
32+
for i, ex := range examples {
33+
ex := ex
34+
35+
t.Run(fmt.Sprintf("prints correctly '%d'", i), func(t *testing.T) {
36+
outBuffer := bytes.NewBufferString("")
37+
errBuffer := bytes.NewBufferString("")
38+
logger := NewRecordingLogger()
39+
ui := NewWriterUI(outBuffer, errBuffer, logger)
40+
w := NewComboWriter(ui).Writer("prefix: ")
41+
42+
for _, in := range ex.Ins {
43+
w.Write([]byte(in))
44+
}
45+
assert.Equal(t, outBuffer.String(), ex.Out)
46+
})
47+
}
48+
}

ui/indenting_ui_test.go

Lines changed: 65 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,129 +2,118 @@ package ui_test
22

33
import (
44
"bytes"
5-
6-
. "github.com/onsi/ginkgo"
7-
. "github.com/onsi/gomega"
5+
"testing"
86

97
. "github.com/cppforlife/go-cli-ui/ui"
108
fakeui "github.com/cppforlife/go-cli-ui/ui/fakes"
119
. "github.com/cppforlife/go-cli-ui/ui/table"
10+
"github.com/stretchr/testify/assert"
1211
)
1312

14-
var _ = Describe("IndentingUI", func() {
15-
var (
16-
uiOut, uiErr *bytes.Buffer
17-
parentFakeUI *fakeui.FakeUI
18-
parentUI UI
19-
ui UI
20-
)
21-
22-
BeforeEach(func() {
23-
uiOut = bytes.NewBufferString("")
24-
uiErr = bytes.NewBufferString("")
25-
26-
logger := NewRecordingLogger()
27-
parentUI = NewWriterUI(uiOut, uiErr, logger)
28-
parentFakeUI = &fakeui.FakeUI{}
29-
})
13+
func TestIndentingUI(t *testing.T) {
14+
t.Run("ErrorLinef", func(t *testing.T) {
15+
t.Run("delegates to the parent UI with an indent", func(t *testing.T) {
16+
uiOut := bytes.NewBufferString("")
17+
uiErr := bytes.NewBufferString("")
18+
parentUI := NewWriterUI(uiOut, uiErr, NewRecordingLogger())
3019

31-
JustBeforeEach(func() {
32-
ui = NewIndentingUI(parentUI)
33-
})
34-
35-
Describe("ErrorLinef", func() {
36-
It("delegates to the parent UI with an indent", func() {
20+
ui := NewIndentingUI(parentUI)
3721
ui.ErrorLinef("fake-error-line")
38-
Expect(uiErr.String()).To(ContainSubstring(" fake-error-line\n"))
39-
Expect(uiOut.String()).To(BeEmpty())
22+
assert.Contains(t, uiErr.String(), " fake-error-line\n")
23+
assert.Equal(t, uiOut.String(), "")
4024
})
4125
})
4226

43-
Describe("PrintLinef", func() {
44-
It("delegates to the parent UI with an indent", func() {
27+
t.Run("PrintLinef", func(t *testing.T) {
28+
t.Run("delegates to the parent UI with an indent", func(t *testing.T) {
29+
uiOut := bytes.NewBufferString("")
30+
uiErr := bytes.NewBufferString("")
31+
parentUI := NewWriterUI(uiOut, uiErr, NewRecordingLogger())
32+
33+
ui := NewIndentingUI(parentUI)
4534
ui.PrintLinef("fake-line")
46-
Expect(uiOut.String()).To(ContainSubstring(" fake-line\n"))
47-
Expect(uiErr.String()).To(BeEmpty())
35+
assert.Contains(t, uiOut.String(), " fake-line\n")
36+
assert.Equal(t, uiErr.String(), "")
4837
})
4938
})
5039

51-
Describe("BeginLinef", func() {
52-
It("delegates to the parent UI with an indent", func() {
40+
t.Run("BeginLinef", func(t *testing.T) {
41+
t.Run("delegates to the parent UI with an indent", func(t *testing.T) {
42+
uiOut := bytes.NewBufferString("")
43+
uiErr := bytes.NewBufferString("")
44+
parentUI := NewWriterUI(uiOut, uiErr, NewRecordingLogger())
45+
46+
ui := NewIndentingUI(parentUI)
5347
ui.BeginLinef("fake-start")
54-
Expect(uiOut.String()).To(ContainSubstring(" fake-start"))
55-
Expect(uiErr.String()).To(BeEmpty())
48+
assert.Contains(t, uiOut.String(), " fake-start")
49+
assert.Equal(t, uiErr.String(), "")
5650
})
5751
})
5852

59-
Describe("EndLinef", func() {
60-
It("delegates to the parent UI", func() {
53+
t.Run("EndLinef", func(t *testing.T) {
54+
t.Run("delegates to the parent UI", func(t *testing.T) {
55+
uiOut := bytes.NewBufferString("")
56+
uiErr := bytes.NewBufferString("")
57+
parentUI := NewWriterUI(uiOut, uiErr, NewRecordingLogger())
58+
59+
ui := NewIndentingUI(parentUI)
6160
ui.EndLinef("fake-end")
62-
Expect(uiOut.String()).To(ContainSubstring("fake-end\n"))
63-
Expect(uiErr.String()).To(BeEmpty())
61+
assert.Contains(t, uiOut.String(), "fake-end\n")
62+
assert.Equal(t, uiErr.String(), "")
6463
})
6564
})
6665

67-
Describe("PrintBlock", func() {
68-
BeforeEach(func() {
69-
parentUI = parentFakeUI
70-
})
71-
72-
It("delegates to the parent UI", func() {
66+
t.Run("PrintBlock", func(t *testing.T) {
67+
t.Run("delegates to the parent UI", func(t *testing.T) {
68+
parentFakeUI := &fakeui.FakeUI{}
69+
ui := NewIndentingUI(parentFakeUI)
7370
ui.PrintBlock([]byte("block"))
74-
Expect(parentFakeUI.Blocks).To(Equal([]string{"block"}))
71+
assert.Equal(t, parentFakeUI.Blocks, []string{"block"})
7572
})
7673
})
7774

78-
Describe("PrintErrorBlock", func() {
79-
BeforeEach(func() {
80-
parentUI = parentFakeUI
81-
})
82-
83-
It("delegates to the parent UI", func() {
75+
t.Run("PrintErrorBlock", func(t *testing.T) {
76+
t.Run("delegates to the parent UI", func(t *testing.T) {
77+
parentFakeUI := &fakeui.FakeUI{}
78+
ui := NewIndentingUI(parentFakeUI)
8479
ui.PrintBlock([]byte("block"))
85-
Expect(parentFakeUI.Blocks).To(Equal([]string{"block"}))
80+
assert.Equal(t, parentFakeUI.Blocks, []string{"block"})
8681
})
8782
})
8883

89-
Describe("PrintTable", func() {
90-
BeforeEach(func() {
91-
parentUI = parentFakeUI
92-
})
93-
94-
It("delegates to the parent UI", func() {
84+
t.Run("PrintTable", func(t *testing.T) {
85+
t.Run("delegates to the parent UI", func(t *testing.T) {
86+
parentFakeUI := &fakeui.FakeUI{}
87+
ui := NewIndentingUI(parentFakeUI)
9588
table := Table{
9689
Content: "things",
9790
Header: []Header{NewHeader("header1")},
9891
}
9992

10093
ui.PrintTable(table)
101-
102-
Expect(parentFakeUI.Table).To(Equal(table))
94+
assert.Equal(t, parentFakeUI.Table, table)
10395
})
10496
})
10597

106-
Describe("IsInteractive", func() {
107-
BeforeEach(func() {
108-
parentUI = parentFakeUI
109-
})
98+
t.Run("IsInteractive", func(t *testing.T) {
99+
t.Run("delegates to the parent UI", func(t *testing.T) {
100+
parentFakeUI := &fakeui.FakeUI{}
101+
ui := NewIndentingUI(parentFakeUI)
110102

111-
It("delegates to the parent UI", func() {
112103
parentFakeUI.Interactive = true
113-
Expect(ui.IsInteractive()).To(BeTrue())
104+
assert.Equal(t, ui.IsInteractive(), true)
114105

115106
parentFakeUI.Interactive = false
116-
Expect(ui.IsInteractive()).To(BeFalse())
107+
assert.Equal(t, ui.IsInteractive(), false)
117108
})
118109
})
119110

120-
Describe("Flush", func() {
121-
BeforeEach(func() {
122-
parentUI = parentFakeUI
123-
})
124-
125-
It("delegates to the parent UI", func() {
111+
t.Run("Flush", func(t *testing.T) {
112+
t.Run("delegates to the parent UI", func(t *testing.T) {
113+
parentFakeUI := &fakeui.FakeUI{}
114+
ui := NewIndentingUI(parentFakeUI)
126115
ui.Flush()
127-
Expect(parentFakeUI.Flushed).To(BeTrue())
116+
assert.Equal(t, parentFakeUI.Flushed, true)
128117
})
129118
})
130-
})
119+
}

0 commit comments

Comments
 (0)