(c *testing.T)
| 107 | } |
| 108 | |
| 109 | func (s *DockerCLICommitSuite) TestCommitChange(c *testing.T) { |
| 110 | cli.DockerCmd(c, "run", "--name", "test", "busybox", "true") |
| 111 | |
| 112 | imageID := cli.DockerCmd(c, "commit", |
| 113 | "--change", `EXPOSE 8080`, |
| 114 | "--change", `ENV DEBUG true`, |
| 115 | "--change", `ENV test 1`, |
| 116 | "--change", `ENV PATH /foo`, |
| 117 | "--change", `LABEL foo bar`, |
| 118 | "--change", `CMD ["/bin/sh"]`, |
| 119 | "--change", `WORKDIR /opt`, |
| 120 | "--change", `ENTRYPOINT ["/bin/sh"]`, |
| 121 | "--change", `USER testuser`, |
| 122 | "--change", `VOLUME /var/lib/docker`, |
| 123 | "--change", `ONBUILD /usr/local/bin/python-build --dir /app/src`, |
| 124 | "test", "test-commit", |
| 125 | ).Stdout() |
| 126 | imageID = strings.TrimSpace(imageID) |
| 127 | |
| 128 | expectedEnv := "[DEBUG=true test=1 PATH=/foo]" |
| 129 | if testEnv.DaemonInfo.OSType != "windows" { |
| 130 | // The ordering here is due to `PATH` being overridden from the container's |
| 131 | // ENV. On windows, the container doesn't have a `PATH` ENV variable so |
| 132 | // the ordering is the same as the cli. |
| 133 | expectedEnv = "[PATH=/foo DEBUG=true test=1]" |
| 134 | } |
| 135 | |
| 136 | prefix, slash := getPrefixAndSlashFromDaemonPlatform() |
| 137 | prefix = strings.ToUpper(prefix) // Force C: as that's how WORKDIR is normalized on Windows |
| 138 | expected := map[string]string{ |
| 139 | "Config.ExposedPorts": "map[8080/tcp:{}]", |
| 140 | "Config.Env": expectedEnv, |
| 141 | "Config.Labels": "map[foo:bar]", |
| 142 | "Config.Cmd": "[/bin/sh]", |
| 143 | "Config.WorkingDir": prefix + slash + "opt", |
| 144 | "Config.Entrypoint": "[/bin/sh]", |
| 145 | "Config.User": "testuser", |
| 146 | "Config.Volumes": "map[/var/lib/docker:{}]", |
| 147 | "Config.OnBuild": "[/usr/local/bin/python-build --dir /app/src]", |
| 148 | } |
| 149 | |
| 150 | for conf, value := range expected { |
| 151 | res := inspectField(c, imageID, conf) |
| 152 | if res != value { |
| 153 | c.Errorf("%s('%s'), expected %s", conf, res, value) |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | func (s *DockerCLICommitSuite) TestCommitChangeLabels(c *testing.T) { |
| 159 | cli.DockerCmd(c, "run", "--name", "test", "--label", "some=label", "busybox", "true") |
nothing calls this directly
no test coverage detected