Skip to content

proposal: assert.MapSubset (or just support maps in assert.Subset) #1173

@SleepyBrett

Description

@SleepyBrett

or perhaps expand subset so it can also handle maps.

given

a := map[string]string{
		"one": "foo",
		"two": "bar",
		"three": "baz",
	 }

b := map[string]string{
		"one": "foo",
		"three": "baz",
	 }

c := map[string]string{
		"one": "foo",
		"three": "notbaz",
	 }


assert.MapSubset(t, a, b, "a does not contain b") // will pass
assert.MapSubset(t, b, a, "b does not contain a") // will fail b does not have two=bar
assert.MapSubset(t, a, c, "a does not contain c") // will fail a does not have three=notbaz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions