Skip to content

Commit

Permalink
diff: add TestBug using structs from real code
Browse files Browse the repository at this point in the history
  • Loading branch information
bmizerany committed May 17, 2022
1 parent 4178042 commit 6c69dcc
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,54 @@ func TestInfLoop(t *testing.T) {
diff.Test(t, t.Errorf, a, b, equal)
}

func TestBug(t *testing.T) {
type Mode string

type Usage struct {
ProviderID string `json:"-"`
}

type Tier struct {
Upto int `json:"upto,omitempty"`
Price int `json:"price,omitempty"`
Base int `json:"base,omitempty"`
}

type Feature struct {
ProviderID string `json:"-"`

Title string `json:"title,omitempty"`

Mode Mode `json:"type,omitempty"`
Reset string `json:"reset,omitempty"`
Aggregate string `json:"-,omitempty"`
Tiers []Tier `json:"tiers,omitempty"`

// Set in LookupSchedule and later reporters of usage
Usage Usage `json:"-"`
}

type Features map[string]Feature

type Schedule struct {
Features Features
}

got := Schedule{
Features: Features{
"foo": Feature{},
},
}

want := Schedule{
Features: Features{
"foo": Feature{},
},
}

diff.Test(t, t.Errorf, got, want)
}

func testUnequal(t *testing.T, a, b any) {
t.Helper()
equal := true
Expand Down

0 comments on commit 6c69dcc

Please sign in to comment.