Browse code

Remove testutil.ConvertSliceOfStringsToMap

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2017/08/22 07:31:51
Showing 3 changed files
... ...
@@ -4,10 +4,10 @@ import (
4 4
 	"encoding/json"
5 5
 	"fmt"
6 6
 	"regexp"
7
+	"sort"
7 8
 	"strings"
8 9
 
9 10
 	"github.com/docker/docker/integration-cli/checker"
10
-	"github.com/docker/docker/pkg/testutil"
11 11
 	"github.com/docker/docker/runconfig"
12 12
 	"github.com/go-check/check"
13 13
 )
... ...
@@ -90,40 +90,41 @@ func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *check.C) {
90 90
 
91 91
 func (s *DockerSuite) TestLinksInspectLinksStarted(c *check.C) {
92 92
 	testRequires(c, DaemonIsLinux)
93
-	var (
94
-		expected = map[string]struct{}{"/container1:/testinspectlink/alias1": {}, "/container2:/testinspectlink/alias2": {}}
95
-		result   []string
96
-	)
97 93
 	dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
98 94
 	dockerCmd(c, "run", "-d", "--name", "container2", "busybox", "top")
99 95
 	dockerCmd(c, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "top")
100 96
 	links := inspectFieldJSON(c, "testinspectlink", "HostConfig.Links")
101 97
 
98
+	var result []string
102 99
 	err := json.Unmarshal([]byte(links), &result)
103 100
 	c.Assert(err, checker.IsNil)
104 101
 
105
-	output := testutil.ConvertSliceOfStringsToMap(result)
106
-
107
-	c.Assert(output, checker.DeepEquals, expected)
102
+	var expected = []string{
103
+		"/container1:/testinspectlink/alias1",
104
+		"/container2:/testinspectlink/alias2",
105
+	}
106
+	sort.Strings(result)
107
+	c.Assert(result, checker.DeepEquals, expected)
108 108
 }
109 109
 
110 110
 func (s *DockerSuite) TestLinksInspectLinksStopped(c *check.C) {
111 111
 	testRequires(c, DaemonIsLinux)
112
-	var (
113
-		expected = map[string]struct{}{"/container1:/testinspectlink/alias1": {}, "/container2:/testinspectlink/alias2": {}}
114
-		result   []string
115
-	)
112
+
116 113
 	dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
117 114
 	dockerCmd(c, "run", "-d", "--name", "container2", "busybox", "top")
118 115
 	dockerCmd(c, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "true")
119 116
 	links := inspectFieldJSON(c, "testinspectlink", "HostConfig.Links")
120 117
 
118
+	var result []string
121 119
 	err := json.Unmarshal([]byte(links), &result)
122 120
 	c.Assert(err, checker.IsNil)
123 121
 
124
-	output := testutil.ConvertSliceOfStringsToMap(result)
125
-
126
-	c.Assert(output, checker.DeepEquals, expected)
122
+	var expected = []string{
123
+		"/container1:/testinspectlink/alias1",
124
+		"/container2:/testinspectlink/alias2",
125
+	}
126
+	sort.Strings(result)
127
+	c.Assert(result, checker.DeepEquals, expected)
127 128
 }
128 129
 
129 130
 func (s *DockerSuite) TestLinksNotStartedParentNotFail(c *check.C) {
... ...
@@ -85,16 +85,6 @@ func RunCommandPipelineWithOutput(cmds ...*exec.Cmd) (output string, exitCode in
85 85
 	return runCommandWithOutput(cmds[len(cmds)-1])
86 86
 }
87 87
 
88
-// ConvertSliceOfStringsToMap converts a slices of string in a map
89
-// with the strings as key and an empty string as values.
90
-func ConvertSliceOfStringsToMap(input []string) map[string]struct{} {
91
-	output := make(map[string]struct{})
92
-	for _, v := range input {
93
-		output[v] = struct{}{}
94
-	}
95
-	return output
96
-}
97
-
98 88
 // CompareDirectoryEntries compares two sets of FileInfo (usually taken from a directory)
99 89
 // and returns an error if different.
100 90
 func CompareDirectoryEntries(e1 []os.FileInfo, e2 []os.FileInfo) error {
... ...
@@ -100,16 +100,6 @@ func TestRunCommandPipelineWithOutput(t *testing.T) {
100 100
 	}
101 101
 }
102 102
 
103
-func TestConvertSliceOfStringsToMap(t *testing.T) {
104
-	input := []string{"a", "b"}
105
-	actual := ConvertSliceOfStringsToMap(input)
106
-	for _, key := range input {
107
-		if _, ok := actual[key]; !ok {
108
-			t.Fatalf("Expected output to contains key %s, did not: %v", key, actual)
109
-		}
110
-	}
111
-}
112
-
113 103
 func TestCompareDirectoryEntries(t *testing.T) {
114 104
 	tmpFolder, err := ioutil.TempDir("", "integration-cli-utils-compare-directories")
115 105
 	if err != nil {