Skip to content

pkg/flags: UniqueURLs'Set cannot deduplicate uss(a slice) #16307

@callthingsoff

Description

@callthingsoff

Bug report criteria

What happened?

Test function UniqueURLsFromFlag:

func TestUniqueURLsFromFlag(t *testing.T) {
	const name = "test"
	urls := []string{
		"https://1.2.3.4:1",
		"https://1.2.3.4:2",
		"https://1.2.3.4:3",
		"https://1.2.3.4:1",
	}
	fs := flag.NewFlagSet(name, flag.ExitOnError)
	u := NewUniqueURLsWithExceptions(strings.Join(urls, ","))
	fs.Var(u, name, "usage")
	uss := UniqueURLsFromFlag(fs, name)

	require.Equal(t, len(u.Values), len(uss))

	um := make(map[string]struct{})
	for _, x := range uss {
		um[x.String()] = struct{}{}
	}
	require.Equal(t, u.Values, um)
}
Error Trace:    /Users/jes/go/src/etcd/pkg/flags/unique_urls_test.go:113
                Error:          Not equal:
                                expected: 3
                                actual  : 4
                Test:           TestUniqueURLsFromFlag

What did you expect to happen?

None

How can we reproduce it (as minimally and precisely as possible)?

Run the test.

Anything else we need to know?

No response

Etcd version (please run commands below)

Sorry, I only reviewed the code and tested it.
No more details could be provided.

Etcd configuration (command line flags or environment variables)

No response

Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)

No response

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions