github.com/openshift/installer@v1.4.17/pkg/asset/quota/aws/aws_test.go (about)

     1  package aws
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  
     9  	"github.com/openshift/installer/pkg/quota"
    10  )
    11  
    12  func Test_aggregate(t *testing.T) {
    13  	cases := []struct {
    14  		input []quota.Constraint
    15  
    16  		exp []quota.Constraint
    17  	}{{
    18  		input: []quota.Constraint{
    19  			{Name: "q1", Region: "g", Count: 1},
    20  			{Name: "q1", Region: "g", Count: 1},
    21  		},
    22  		exp: []quota.Constraint{
    23  			{Name: "q1", Region: "g", Count: 2},
    24  		},
    25  	}, {
    26  		input: []quota.Constraint{
    27  			{Name: "q1", Region: "g", Count: 1},
    28  			{Name: "q2", Region: "r1", Count: 1},
    29  			{Name: "q3", Region: "r1", Count: 1},
    30  			{Name: "q2", Region: "r1", Count: 1},
    31  		},
    32  		exp: []quota.Constraint{
    33  			{Name: "q1", Region: "g", Count: 1},
    34  			{Name: "q2", Region: "r1", Count: 2},
    35  			{Name: "q3", Region: "r1", Count: 1},
    36  		},
    37  	}, {
    38  		input: []quota.Constraint{
    39  			{Name: "q1", Region: "g", Count: 1},
    40  			{Name: "q2", Region: "r1", Count: 1},
    41  			{Name: "q3", Region: "r1", Count: 1},
    42  			{Name: "q4", Region: "r1", Count: 1},
    43  		},
    44  		exp: []quota.Constraint{
    45  			{Name: "q1", Region: "g", Count: 1},
    46  			{Name: "q2", Region: "r1", Count: 1},
    47  			{Name: "q3", Region: "r1", Count: 1},
    48  			{Name: "q4", Region: "r1", Count: 1},
    49  		},
    50  	}}
    51  
    52  	for idx, test := range cases {
    53  		t.Run(fmt.Sprintf("test %d", idx), func(t *testing.T) {
    54  			got := aggregate(test.input)
    55  			assert.EqualValues(t, test.exp, got)
    56  		})
    57  	}
    58  }