...

Source file src/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/internal/config/resolvers_test.go

Documentation: github.com/aws/aws-sdk-go-v2/feature/ec2/imds/internal/config

     1  package config
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestEndpointMode_SetFromString(t *testing.T) {
     9  	cases := map[string]struct {
    10  		Value   string
    11  		Expect  EndpointModeState
    12  		WantErr bool
    13  	}{
    14  		"empty value": {
    15  			Expect: EndpointModeStateUnset,
    16  		},
    17  		"unknown value": {
    18  			Value:   "foobar",
    19  			WantErr: true,
    20  		},
    21  		"IPv4": {
    22  			Value:  "IPv4",
    23  			Expect: EndpointModeStateIPv4,
    24  		},
    25  		"IPv6": {
    26  			Value:  "IPv6",
    27  			Expect: EndpointModeStateIPv6,
    28  		},
    29  		"IPv4 case-insensitive": {
    30  			Value:  "iPv4",
    31  			Expect: EndpointModeStateIPv4,
    32  		},
    33  		"IPv6 case-insensitive": {
    34  			Value:  "iPv6",
    35  			Expect: EndpointModeStateIPv6,
    36  		},
    37  	}
    38  
    39  	for name, tt := range cases {
    40  		t.Run(name, func(t *testing.T) {
    41  			var em EndpointModeState
    42  			if err := em.SetFromString(tt.Value); (err != nil) != tt.WantErr {
    43  				t.Fatalf("WantErr=%v, got err=%v", tt.WantErr, err)
    44  			}
    45  			if !reflect.DeepEqual(tt.Expect, em) {
    46  				t.Errorf("%v != %v", tt.Expect, em)
    47  			}
    48  		})
    49  	}
    50  }
    51  

View as plain text