Skip to content

Commit 02e2cff

Browse files
committed
tests: simplify
1 parent d4f0d83 commit 02e2cff

File tree

4 files changed

+33
-44
lines changed

4 files changed

+33
-44
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.18
44

55
require (
66
github.com/ettle/strcase v0.1.1
7-
github.com/hexops/gotextdiff v1.0.3
87
github.com/stretchr/testify v1.7.4
98
)
109

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/ettle/strcase v0.1.1 h1:htFueZyVeE1XNnMEfbqp5r67qAN/4r6ya1ysq8Q+Zcw=
55
github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY=
6-
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
7-
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
86
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
97
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
108
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

mocktail_test.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
package main
22

33
import (
4-
"fmt"
54
"io/fs"
65
"os"
76
"os/exec"
87
"path/filepath"
98
"runtime"
109
"testing"
1110

12-
"github.com/hexops/gotextdiff"
13-
"github.com/hexops/gotextdiff/myers"
14-
"github.com/hexops/gotextdiff/span"
11+
"github.com/stretchr/testify/assert"
1512
"github.com/stretchr/testify/require"
1613
)
1714

@@ -53,12 +50,7 @@ func TestMocktail(t *testing.T) {
5350
goldenBytes, err := os.ReadFile(path + ".golden")
5451
require.NoError(t, err)
5552

56-
edits := myers.ComputeEdits(span.URIFromPath(d.Name()), string(genBytes), string(goldenBytes))
57-
58-
if len(edits) > 0 {
59-
diff := fmt.Sprint(gotextdiff.ToUnified(d.Name(), d.Name()+".golden", string(genBytes), edits))
60-
t.Error(diff)
61-
}
53+
assert.Equal(t, string(goldenBytes), string(genBytes))
6254

6355
return nil
6456
})

syrup.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -220,37 +220,6 @@ func (s Syrup) writeReturnsFnCaller(w *Writer, argNames []string, params, result
220220
}
221221
}
222222

223-
func (s Syrup) createFuncSignature(params, results *types.Tuple) string {
224-
fnSign := "func("
225-
for i := 0; i < params.Len(); i++ {
226-
param := params.At(i)
227-
if param.Type().String() == contextType {
228-
continue
229-
}
230-
231-
fnSign += s.getTypeName(param.Type(), i == params.Len()-1)
232-
233-
if i+1 < params.Len() {
234-
fnSign += ", "
235-
}
236-
}
237-
fnSign += ") "
238-
239-
if results != nil {
240-
fnSign += "("
241-
for i := 0; i < results.Len(); i++ {
242-
rType := results.At(i).Type()
243-
fnSign += s.getTypeName(rType, false)
244-
if i+1 < results.Len() {
245-
fnSign += ", "
246-
}
247-
}
248-
fnSign += ")"
249-
}
250-
251-
return fnSign
252-
}
253-
254223
func (s Syrup) methodOn(writer io.Writer) error {
255224
w := &Writer{writer: writer}
256225

@@ -651,6 +620,37 @@ func (s Syrup) getTupleTypes(t *types.Tuple) []string {
651620
return tupleTypes
652621
}
653622

623+
func (s Syrup) createFuncSignature(params, results *types.Tuple) string {
624+
fnSign := "func("
625+
for i := 0; i < params.Len(); i++ {
626+
param := params.At(i)
627+
if param.Type().String() == contextType {
628+
continue
629+
}
630+
631+
fnSign += s.getTypeName(param.Type(), i == params.Len()-1)
632+
633+
if i+1 < params.Len() {
634+
fnSign += ", "
635+
}
636+
}
637+
fnSign += ") "
638+
639+
if results != nil {
640+
fnSign += "("
641+
for i := 0; i < results.Len(); i++ {
642+
rType := results.At(i).Type()
643+
fnSign += s.getTypeName(rType, false)
644+
if i+1 < results.Len() {
645+
fnSign += ", "
646+
}
647+
}
648+
fnSign += ")"
649+
}
650+
651+
return fnSign
652+
}
653+
654654
func writeImports(writer io.Writer, descPkg PackageDesc) error {
655655
base := template.New("templateImports")
656656

0 commit comments

Comments
 (0)