From af57bc6726e41fdaadfaa461d5653dc6f4133ae8 Mon Sep 17 00:00:00 2001 From: Jacob Brewer Date: Thu, 24 Oct 2024 08:00:58 +0100 Subject: [PATCH] feat(loader): Adding test for not pointed embedded struct (#49) Adding test for not pointed embedded struct --- loader_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/loader_test.go b/loader_test.go index 5d7b580..d3f7568 100644 --- a/loader_test.go +++ b/loader_test.go @@ -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