Skip to content

Commit

Permalink
refactor: user struct to for and bar in debug tests to improve tests …
Browse files Browse the repository at this point in the history
…abstraction

gohugoio#9148 and rebased gohugoio#10806
  • Loading branch information
zepyrshut committed Nov 12, 2024
1 parent 36df350 commit c91de88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 0 additions & 2 deletions tpl/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (
"reflect"
"sort"

"github.com/sanity-io/litter"
"encoding/json"
"sort"
"sync"
"time"

Expand Down
21 changes: 10 additions & 11 deletions tpl/debug/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ import (
"testing"
)

type User struct {
Name string
Address any
foo string
type Foo struct {
Bar string
foo any
}

func (u *User) M1() string { return "" }
func (u *User) M2(v string) string { return "" }
func (u *User) m3(v string) string { return "" }
func (f *Foo) M1() string { return "" }
func (f *Foo) M2(v string) string { return "" }
func (f *Foo) m3(v string) string { return "" }

// Non Pointer type methods
func (u User) M4(v string) string { return "" }
func (u User) m5(v string) string { return "" }
func (f Foo) M4(v string) string { return "" }
func (f Foo) m5(v string) string { return "" }

func TestList(t *testing.T) {
t.Parallel()
Expand All @@ -46,9 +45,9 @@ func TestList(t *testing.T) {
// Map non string keys
{map[int]any{1: 1, 2: 2, 3: 3}, []string{"<int Value>", "<int Value>", "<int Value>"}},
// Struct
{User{}, []string{"Name", "Address", "M1", "M2", "M4"}},
{Foo{}, []string{"Bar", "M1", "M2", "M4"}},
// 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) {
result := namespace.List(test.val)
Expand Down

0 comments on commit c91de88

Please sign in to comment.