From 3d73d32499cb13c08db45354cbe1a6bc97541c5b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 31 Oct 2022 15:16:59 +0100 Subject: [PATCH] api/types/filters: add output to example Make the example actually do something, and include the output, so that it shows up in the documentation. Signed-off-by: Sebastiaan van Stijn --- api/types/filters/example_test.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/api/types/filters/example_test.go b/api/types/filters/example_test.go index c8fec1b9d8..3e11a59a78 100644 --- a/api/types/filters/example_test.go +++ b/api/types/filters/example_test.go @@ -1,4 +1,5 @@ package filters // import "github.com/docker/docker/api/types/filters" +import "fmt" func ExampleArgs_MatchKVList() { args := NewArgs( @@ -6,19 +7,29 @@ func ExampleArgs_MatchKVList() { Arg("label", "state=running")) // returns true because there are no values for bogus - args.MatchKVList("bogus", nil) + b := args.MatchKVList("bogus", nil) + fmt.Println(b) // returns false because there are no sources - args.MatchKVList("label", nil) + b = args.MatchKVList("label", nil) + fmt.Println(b) // returns true because all sources are matched - args.MatchKVList("label", map[string]string{ + b = args.MatchKVList("label", map[string]string{ "image": "foo", "state": "running", }) + fmt.Println(b) // returns false because the values do not match - args.MatchKVList("label", map[string]string{ + b = args.MatchKVList("label", map[string]string{ "image": "other", }) + fmt.Println(b) + + // Output: + // true + // false + // true + // false }