mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
refactor: user struct to for and bar in debug tests to improve tests abstraction
#9148 and rebased #10806
This commit is contained in:
parent
36df350f52
commit
c91de885b5
2 changed files with 10 additions and 13 deletions
|
@ -18,9 +18,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/sanity-io/litter"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"sort"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
|
@ -18,19 +18,18 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type Foo struct {
|
||||||
Name string
|
Bar string
|
||||||
Address any
|
foo any
|
||||||
foo string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) M1() string { return "" }
|
func (f *Foo) M1() string { return "" }
|
||||||
func (u *User) M2(v string) string { return "" }
|
func (f *Foo) M2(v string) string { return "" }
|
||||||
func (u *User) m3(v string) string { return "" }
|
func (f *Foo) m3(v string) string { return "" }
|
||||||
|
|
||||||
// Non Pointer type methods
|
// Non Pointer type methods
|
||||||
func (u User) M4(v string) string { return "" }
|
func (f Foo) M4(v string) string { return "" }
|
||||||
func (u User) m5(v string) string { return "" }
|
func (f Foo) m5(v string) string { return "" }
|
||||||
|
|
||||||
func TestList(t *testing.T) {
|
func TestList(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -46,9 +45,9 @@ func TestList(t *testing.T) {
|
||||||
// Map non string keys
|
// Map non string keys
|
||||||
{map[int]any{1: 1, 2: 2, 3: 3}, []string{"<int Value>", "<int Value>", "<int Value>"}},
|
{map[int]any{1: 1, 2: 2, 3: 3}, []string{"<int Value>", "<int Value>", "<int Value>"}},
|
||||||
// Struct
|
// Struct
|
||||||
{User{}, []string{"Name", "Address", "M1", "M2", "M4"}},
|
{Foo{}, []string{"Bar", "M1", "M2", "M4"}},
|
||||||
// Pointer
|
// Pointer
|
||||||
{&User{}, []string{"Name", "Address", "M1", "M2", "M4"}},
|
{&Foo{}, []string{"Bar", "M1", "M2", "M4"}},
|
||||||
} {
|
} {
|
||||||
t.Run(fmt.Sprintf("test%d", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("test%d", i), func(t *testing.T) {
|
||||||
result := namespace.List(test.val)
|
result := namespace.List(test.val)
|
||||||
|
|
Loading…
Reference in a new issue