Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gotests generate test names with MixedCaps #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,11 @@ func (f *Function) TestName() string {
if f.Receiver != nil {
receiverType := f.Receiver.Type.Value
if unicode.IsLower([]rune(receiverType)[0]) {
receiverType = "_" + receiverType
receiverType = strings.Title(receiverType)
}
return "Test" + receiverType + "_" + f.Name
return "Test" + receiverType + strings.Title(f.Name)
}
if unicode.IsLower([]rune(f.Name)[0]) {
return "Test_" + f.Name
}
return "Test" + f.Name
return "Test" + strings.Title(f.Name)
}

func (f *Function) IsNaked() bool {
Expand Down
10 changes: 5 additions & 5 deletions testdata/goldens/custom_importer_fails.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestFooFilter(t *testing.T) {
want []*Bar
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
got, err := FooFilter(tt.args.strs)
Expand All @@ -29,7 +29,7 @@ func TestFooFilter(t *testing.T) {
}
}

func TestBar_BarFilter(t *testing.T) {
func TestBarBarFilter(t *testing.T) {
type args struct {
i interface{}
}
Expand All @@ -39,7 +39,7 @@ func TestBar_BarFilter(t *testing.T) {
args args
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
b := &Bar{}
Expand All @@ -49,7 +49,7 @@ func TestBar_BarFilter(t *testing.T) {
}
}

func Test_bazFilter(t *testing.T) {
func TestBazFilter(t *testing.T) {
type args struct {
f *float64
}
Expand All @@ -58,7 +58,7 @@ func Test_bazFilter(t *testing.T) {
args args
want float64
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
if got := bazFilter(tt.args.f); got != tt.want {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package bar

import "testing"

func TestBar_Bar(t *testing.T) {
func TestBarBar(t *testing.T) {
type fields struct {
Foo string
}
Expand All @@ -15,7 +15,7 @@ func TestBar_Bar(t *testing.T) {
args args
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
b := &Bar{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package foo

import "testing"

func TestFoo_Foo(t *testing.T) {
func TestFooFoo(t *testing.T) {
type fields struct {
Bar string
}
Expand All @@ -15,7 +15,7 @@ func TestFoo_Foo(t *testing.T) {
args args
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
f := &Foo{
Expand Down
40 changes: 1 addition & 39 deletions testdata/goldens/existing_test_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestFoo100(t *testing.T) {
want []*Bar
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
got, err := Foo100(tt.args.strs)
Expand All @@ -68,41 +68,3 @@ func TestFoo100(t *testing.T) {
}
}
}

func TestBar_Bar100(t *testing.T) {
type args struct {
i interface{}
}
tests := []struct {
name string
b *Bar
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
b := &Bar{}
if err := b.Bar100(tt.args.i); (err != nil) != tt.wantErr {
t.Errorf("%q. Bar.Bar100() error = %v, wantErr %v", tt.name, err, tt.wantErr)
}
}
}

func Test_baz100(t *testing.T) {
type args struct {
f *float64
}
tests := []struct {
name string
args args
want float64
}{
// TODO: Add test cases.
}
for _, tt := range tests {
if got := baz100(tt.args.f); got != tt.want {
t.Errorf("%q. baz100() = %v, want %v", tt.name, got, tt.want)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package testdata

import "testing"

func Test_name_Name(t *testing.T) {
func TestNameName(t *testing.T) {
type args struct {
n string
}
Expand All @@ -12,7 +12,7 @@ func Test_name_Name(t *testing.T) {
args args
want string
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
if got := tt.n.Name(tt.args.n); got != tt.want {
Expand All @@ -21,7 +21,7 @@ func Test_name_Name(t *testing.T) {
}
}

func TestName_Name1(t *testing.T) {
func TestNameName1(t *testing.T) {
type fields struct {
Name string
}
Expand All @@ -34,7 +34,7 @@ func TestName_Name1(t *testing.T) {
args args
want string
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
n := &Name{
Expand All @@ -46,7 +46,7 @@ func TestName_Name1(t *testing.T) {
}
}

func TestName_Name2(t *testing.T) {
func TestNameName2(t *testing.T) {
type fields struct {
Name string
}
Expand All @@ -59,7 +59,7 @@ func TestName_Name2(t *testing.T) {
args args
want string
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
n := &Name{
Expand All @@ -71,7 +71,7 @@ func TestName_Name2(t *testing.T) {
}
}

func TestName_Name3(t *testing.T) {
func TestNameName3(t *testing.T) {
type fields struct {
Name string
}
Expand All @@ -84,7 +84,7 @@ func TestName_Name3(t *testing.T) {
args args
wantName string
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
n := &Name{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func TestSameName(t *testing.T) {
want int
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
got, err := SameName()
Expand All @@ -22,13 +22,13 @@ func TestSameName(t *testing.T) {
}
}

func Test_sameName(t *testing.T) {
func TestSameName(t *testing.T) {
tests := []struct {
name string
want int
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
got, err := sameName()
Expand All @@ -42,14 +42,14 @@ func Test_sameName(t *testing.T) {
}
}

func TestSameTypeName_SameName(t *testing.T) {
func TestSameTypeNameSameName(t *testing.T) {
tests := []struct {
name string
t *SameTypeName
want int
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
t := &SameTypeName{}
Expand All @@ -64,14 +64,14 @@ func TestSameTypeName_SameName(t *testing.T) {
}
}

func TestSameTypeName_sameName(t *testing.T) {
func TestSameTypeNameSameName(t *testing.T) {
tests := []struct {
name string
t *SameTypeName
want int
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
t := &SameTypeName{}
Expand All @@ -86,14 +86,14 @@ func TestSameTypeName_sameName(t *testing.T) {
}
}

func Test_sameTypeName_SameName(t *testing.T) {
func TestSameTypeNameSameName(t *testing.T) {
tests := []struct {
name string
t *sameTypeName
want int
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
t := &sameTypeName{}
Expand All @@ -108,14 +108,14 @@ func Test_sameTypeName_SameName(t *testing.T) {
}
}

func Test_sameTypeName_sameName(t *testing.T) {
func TestSameTypeNameSameName(t *testing.T) {
tests := []struct {
name string
t *sameTypeName
want int
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
t := &sameTypeName{}
Expand Down
8 changes: 4 additions & 4 deletions testdata/goldens/io_writer_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"testing"
)

func TestBar_Write(t *testing.T) {
func TestBarWrite(t *testing.T) {
tests := []struct {
name string
b *Bar
wantW string
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
b := &Bar{}
Expand All @@ -37,7 +37,7 @@ func TestWrite(t *testing.T) {
wantW string
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
w := &bytes.Buffer{}
Expand All @@ -64,7 +64,7 @@ func TestMultiWrite(t *testing.T) {
wantW2 string
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
w1 := &bytes.Buffer{}
Expand Down
4 changes: 2 additions & 2 deletions testdata/goldens/method_on_a_struct_pointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package testdata

import "testing"

func TestBar_Foo7(t *testing.T) {
func TestBarFoo7(t *testing.T) {
type args struct {
i int
}
Expand All @@ -13,7 +13,7 @@ func TestBar_Foo7(t *testing.T) {
want string
wantErr bool
}{
// TODO: Add test cases.
// TODO: Add test cases.
}
for _, tt := range tests {
b := &Bar{}
Expand Down
Loading