...

Source file src/edge-infra.dev/pkg/f8n/warehouse/lift/pack/package_test.go

Documentation: edge-infra.dev/pkg/f8n/warehouse/lift/pack

     1  package pack
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"edge-infra.dev/pkg/f8n/warehouse/lift"
     9  )
    10  
    11  var (
    12  	dummyInfraCfg = lift.CapabilityConfig{
    13  		Package: "fake/infra-package",
    14  		ResourceMatcher: lift.ResourceMatcher{
    15  			APIGroups: []string{"fake.apigroup.u"},
    16  		},
    17  	}
    18  )
    19  
    20  func TestMergeConfig(t *testing.T) {
    21  	tcs := map[string]struct {
    22  		src lift.Config
    23  		dst lift.Config
    24  		exp lift.Config
    25  	}{
    26  		"destination is preserved if source is empty": {
    27  			src: lift.Config{},
    28  			dst: lift.Config{Infrastructure: dummyInfraCfg},
    29  			exp: lift.Config{Infrastructure: dummyInfraCfg},
    30  		},
    31  		"source overrides destination": {
    32  			src: lift.Config{Infrastructure: lift.CapabilityConfig{
    33  				Package:         "fake/alternative-infra-package",
    34  				ResourceMatcher: lift.ResourceMatcher{},
    35  			}},
    36  			dst: lift.Config{Infrastructure: dummyInfraCfg},
    37  			exp: lift.Config{Infrastructure: lift.CapabilityConfig{
    38  				Package:         "fake/alternative-infra-package",
    39  				ResourceMatcher: lift.ResourceMatcher{},
    40  			}},
    41  		},
    42  	}
    43  
    44  	for name, tc := range tcs {
    45  		t.Run(name, func(t *testing.T) {
    46  			actual, _ := mergeCfg(tc.src, tc.dst)
    47  			assert.Equal(t, tc.exp, actual)
    48  		})
    49  	}
    50  }
    51  

View as plain text