Skip to content

Commit

Permalink
feat(loader): Adding test for not pointed embedded struct (#49)
Browse files Browse the repository at this point in the history
Adding test for not pointed embedded struct
  • Loading branch information
Jacobbrewer1 authored Oct 24, 2024
1 parent d62ca81 commit af57bc6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,37 @@ func (s *loadDiffSuite) TestLoadDiff_Success_EmbeddedStruct_NotPointed() {
s.Equal(24, old.Partner.Age)
}

func (s *loadDiffSuite) TestLoadDiff_Success_InheritedStruct_NotPointed() {
type TestEmbed struct {
Description string
}

type testStruct struct {
TestEmbed
Name string
Age int
}

old := testStruct{
Name: "John",
Age: 25,
}

n := testStruct{
TestEmbed: TestEmbed{
Description: "Some description",
},
Name: "John Smith",
Age: 26,
}

err := s.l.loadDiff(&old, &n)
s.NoError(err)
s.Equal("John Smith", old.Name)
s.Equal(26, old.Age)
s.Equal("Some description", old.Description)
}

func (s *loadDiffSuite) TestLoadDiff_Success_EmbeddedStructWithNewValue() {
type testStruct struct {
Name string
Expand Down

0 comments on commit af57bc6

Please sign in to comment.