modernize: Use slices.Contains

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-12-15 18:27:58 +01:00
parent bce14ac5bc
commit 62ed24a87c
18 changed files with 50 additions and 107 deletions

View File

@@ -12,6 +12,7 @@ import (
"reflect"
"regexp"
"runtime"
"slices"
"strconv"
"strings"
"testing"
@@ -4357,13 +4358,7 @@ func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgExpansion(c *testing.T) {
var resArr []string
inspectFieldAndUnmarshall(c, imgName, "Config.Env", &resArr)
found := false
for _, v := range resArr {
if fmt.Sprintf("%s=%s", envVar, envVal) == v {
found = true
break
}
}
found := slices.Contains(resArr, fmt.Sprintf("%s=%s", envVar, envVal))
if !found {
c.Fatalf("Config.Env value mismatch. Expected <key=value> to exist: %s=%s, got: %v",
envVar, envVal, resArr)
@@ -4707,11 +4702,8 @@ func (s *DockerCLIBuildSuite) TestBuildTagEvent(c *testing.T) {
events := strings.Split(strings.TrimSpace(out), "\n")
actions := eventActionsByIDAndType(c, events, imgName+":latest", "image")
var foundTag bool
for _, a := range actions {
if a == "tag" {
foundTag = true
break
}
if slices.Contains(actions, "tag") {
foundTag = true
}
assert.Assert(c, foundTag, "No tag event found:\n%s", out)