github.com/etecs-ru/gnomock@v0.13.2/preset/localstack/preset_internal_test.go (about)

     1  package localstack
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/etecs-ru/gnomock"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestHealthCheckAddress(t *testing.T) {
    11  	legacyPath := "http://127.0.0.1:33333/health"
    12  	newPath := "http://127.0.0.1:44444/health"
    13  	tests := []struct {
    14  		version  string
    15  		expected string
    16  	}{
    17  		{
    18  			version:  "0.10.0",
    19  			expected: legacyPath,
    20  		},
    21  		{
    22  			version:  "unexpected",
    23  			expected: newPath,
    24  		},
    25  		{
    26  			version:  "latest",
    27  			expected: newPath,
    28  		},
    29  		{
    30  			version:  "0.12.9",
    31  			expected: newPath,
    32  		},
    33  		{
    34  			version:  "1.10.0",
    35  			expected: newPath,
    36  		},
    37  		{
    38  			version:  "0.12.0",
    39  			expected: newPath,
    40  		},
    41  		{
    42  			version:  "0.10.4",
    43  			expected: legacyPath,
    44  		},
    45  		{
    46  			version:  "0.11.3",
    47  			expected: newPath,
    48  		},
    49  		{
    50  			version:  "0.11.4",
    51  			expected: newPath,
    52  		},
    53  		{
    54  			version:  "foo.11.4",
    55  			expected: newPath,
    56  		},
    57  		{
    58  			version:  "0.foo.4",
    59  			expected: newPath,
    60  		},
    61  		{
    62  			version:  "0.11.foo",
    63  			expected: newPath,
    64  		},
    65  	}
    66  
    67  	c := &gnomock.Container{
    68  		Host: "127.0.0.1",
    69  		Ports: gnomock.NamedPorts{
    70  			"web": gnomock.Port{
    71  				Protocol: "tcp",
    72  				Port:     33333,
    73  			},
    74  			"api": gnomock.Port{
    75  				Protocol: "tcp",
    76  				Port:     44444,
    77  			},
    78  		},
    79  	}
    80  
    81  	for _, test := range tests {
    82  		test := test
    83  
    84  		t.Run(test.version, func(t *testing.T) {
    85  			p := P{Version: test.version}
    86  			actual := p.healthCheckAddress(c)
    87  			require.Equal(t, test.expected, actual)
    88  		})
    89  	}
    90  }