Skip to content

Commit c91de88

Browse files
committed
refactor: user struct to for and bar in debug tests to improve tests abstraction
gohugoio#9148 and rebased gohugoio#10806
1 parent 36df350 commit c91de88

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

‎tpl/debug/debug.go‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import (
1818
"reflect"
1919
"sort"
2020

21-
"github.com/sanity-io/litter"
2221
"encoding/json"
23-
"sort"
2422
"sync"
2523
"time"
2624

‎tpl/debug/debug_test.go‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@ import (
1818
"testing"
1919
)
2020

21-
type User struct {
22-
Name string
23-
Address any
24-
foo string
21+
type Foo struct {
22+
Bar string
23+
foo any
2524
}
2625

27-
func (u *User) M1() string { return "" }
28-
func (u *User) M2(v string) string { return "" }
29-
func (u *User) m3(v string) string { return "" }
26+
func (f *Foo) M1() string { return "" }
27+
func (f *Foo) M2(v string) string { return "" }
28+
func (f *Foo) m3(v string) string { return "" }
3029

3130
// Non Pointer type methods
32-
func (u User) M4(v string) string { return "" }
33-
func (u User) m5(v string) string { return "" }
31+
func (f Foo) M4(v string) string { return "" }
32+
func (f Foo) m5(v string) string { return "" }
3433

3534
func TestList(t *testing.T) {
3635
t.Parallel()
@@ -46,9 +45,9 @@ func TestList(t *testing.T) {
4645
// Map non string keys
4746
{map[int]any{1: 1, 2: 2, 3: 3}, []string{"<int Value>", "<int Value>", "<int Value>"}},
4847
// Struct
49-
{User{}, []string{"Name", "Address", "M1", "M2", "M4"}},
48+
{Foo{}, []string{"Bar", "M1", "M2", "M4"}},
5049
// Pointer
51-
{&User{}, []string{"Name", "Address", "M1", "M2", "M4"}},
50+
{&Foo{}, []string{"Bar", "M1", "M2", "M4"}},
5251
} {
5352
t.Run(fmt.Sprintf("test%d", i), func(t *testing.T) {
5453
result := namespace.List(test.val)

0 commit comments

Comments
 (0)