File: resolvers_test.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.30.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 662,428 kB
  • sloc: java: 16,875; makefile: 432; sh: 175
file content (50 lines) | stat: -rw-r--r-- 961 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package config

import (
	"reflect"
	"testing"
)

func TestEndpointMode_SetFromString(t *testing.T) {
	cases := map[string]struct {
		Value   string
		Expect  EndpointModeState
		WantErr bool
	}{
		"empty value": {
			Expect: EndpointModeStateUnset,
		},
		"unknown value": {
			Value:   "foobar",
			WantErr: true,
		},
		"IPv4": {
			Value:  "IPv4",
			Expect: EndpointModeStateIPv4,
		},
		"IPv6": {
			Value:  "IPv6",
			Expect: EndpointModeStateIPv6,
		},
		"IPv4 case-insensitive": {
			Value:  "iPv4",
			Expect: EndpointModeStateIPv4,
		},
		"IPv6 case-insensitive": {
			Value:  "iPv6",
			Expect: EndpointModeStateIPv6,
		},
	}

	for name, tt := range cases {
		t.Run(name, func(t *testing.T) {
			var em EndpointModeState
			if err := em.SetFromString(tt.Value); (err != nil) != tt.WantErr {
				t.Fatalf("WantErr=%v, got err=%v", tt.WantErr, err)
			}
			if !reflect.DeepEqual(tt.Expect, em) {
				t.Errorf("%v != %v", tt.Expect, em)
			}
		})
	}
}