gitlab.com/evatix-go/core@v1.3.55/tests/creationtests/enumimpltests/DynamicMapCreation_test.go (about)

     1  package enumimpltests
     2  
     3  import (
     4  	"testing"
     5  
     6  	. "github.com/smartystreets/goconvey/convey"
     7  	"gitlab.com/evatix-go/core/coredata/coredynamic"
     8  )
     9  
    10  func Test_DynamicMapCreationDiff(t *testing.T) {
    11  	for caseIndex, testCase := range dynamicMapDiffTestCases {
    12  		// Arrange
    13  		arrangeInput := testCase.ArrangeAsLeftRightDynamicMap()
    14  		diffMap := arrangeInput.Left.DiffRaw(
    15  			true,
    16  			arrangeInput.Right)
    17  		mapAnyDiffer := coredynamic.MapAnyItemDiff(
    18  			arrangeInput.Left)
    19  
    20  		// Act
    21  		anotherDiff := mapAnyDiffer.
    22  			DiffRaw(
    23  				true,
    24  				arrangeInput.Right)
    25  
    26  		// Assert
    27  		testCase.ShouldBe(
    28  			caseIndex,
    29  			t,
    30  			ShouldResemble,
    31  			diffMap)
    32  		testCase.ShouldBeExplicit(
    33  			false,
    34  			caseIndex,
    35  			t,
    36  			"both diff should be equal",
    37  			diffMap.Raw(),
    38  			ShouldResemble,
    39  			anotherDiff)
    40  	}
    41  }
    42  
    43  func Test_DynamicMapCreationDiffMessage(t *testing.T) {
    44  	for caseIndex, testCase := range dynamicMapDiffMessageTestCases {
    45  		// Arrange
    46  		arrangeInput := testCase.ArrangeAsLeftRightDynamicMap()
    47  
    48  		// Act
    49  		diffJsonMessage := arrangeInput.Left.ShouldDiffMessage(
    50  			true,
    51  			testCase.CaseTitle(),
    52  			arrangeInput.Right)
    53  
    54  		// Assert
    55  		testCase.ShouldBe(
    56  			caseIndex,
    57  			t,
    58  			ShouldResemble,
    59  			diffJsonMessage)
    60  	}
    61  }