From c91de885b578639e30e66040cf919d4c73d44f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20P=C3=A9rez?= Date: Tue, 12 Nov 2024 17:12:58 +0100 Subject: [PATCH] refactor: user struct to for and bar in debug tests to improve tests abstraction #9148 and rebased #10806 --- tpl/debug/debug.go | 2 -- tpl/debug/debug_test.go | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tpl/debug/debug.go b/tpl/debug/debug.go index 120f9b773..3f771856f 100644 --- a/tpl/debug/debug.go +++ b/tpl/debug/debug.go @@ -18,9 +18,7 @@ import ( "reflect" "sort" - "github.com/sanity-io/litter" "encoding/json" - "sort" "sync" "time" diff --git a/tpl/debug/debug_test.go b/tpl/debug/debug_test.go index 133db11bf..86f767a62 100644 --- a/tpl/debug/debug_test.go +++ b/tpl/debug/debug_test.go @@ -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() @@ -46,9 +45,9 @@ func TestList(t *testing.T) { // Map non string keys {map[int]any{1: 1, 2: 2, 3: 3}, []string{"", "", ""}}, // 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)