(t *testing.T)
| 156 | } |
| 157 | |
| 158 | func TestPublish(t *testing.T) { |
| 159 | c := NewParallelCLI(t) |
| 160 | const projectName = "compose-e2e-publish" |
| 161 | const registryName = projectName + "-registry" |
| 162 | c.RunDockerCmd(t, "run", "--name", registryName, "-P", "-d", "registry:3") |
| 163 | port := c.RunDockerCmd(t, "inspect", "--format", `{{ (index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort }}`, registryName).Stdout() |
| 164 | registry := "localhost:" + strings.TrimSpace(port) |
| 165 | t.Cleanup(func() { |
| 166 | c.RunDockerCmd(t, "rm", "--force", registryName) |
| 167 | }) |
| 168 | |
| 169 | // Wait for registry to be ready |
| 170 | registryURL := "http://" + registry + "/v2/" |
| 171 | poll.WaitOn(t, func(l poll.LogT) poll.Result { |
| 172 | resp, err := http.Get(registryURL) //nolint:gosec,noctx |
| 173 | if err != nil { |
| 174 | return poll.Continue("registry not ready: %v", err) |
| 175 | } |
| 176 | _ = resp.Body.Close() |
| 177 | if resp.StatusCode < 500 { |
| 178 | return poll.Success() |
| 179 | } |
| 180 | return poll.Continue("registry not ready, status %d", resp.StatusCode) |
| 181 | }, poll.WithTimeout(10*time.Second), poll.WithDelay(100*time.Millisecond)) |
| 182 | |
| 183 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/publish/oci/compose.yaml", "-f", "./fixtures/publish/oci/compose-override.yaml", |
| 184 | "-p", projectName, "publish", "--with-env", "--yes", "--insecure-registry", registry+"/test:test") |
| 185 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 186 | |
| 187 | // docker exec -it compose-e2e-publish-registry tree /var/lib/registry/docker/registry/v2/ |
| 188 | |
| 189 | cmd := c.NewDockerComposeCmd(t, "--verbose", "--project-name=oci", |
| 190 | "--insecure-registry", registry, |
| 191 | "-f", fmt.Sprintf("oci://%s/test:test", registry), "config") |
| 192 | res = icmd.RunCmd(cmd, func(cmd *icmd.Cmd) { |
| 193 | cmd.Env = append(cmd.Env, "XDG_CACHE_HOME="+t.TempDir()) |
| 194 | }) |
| 195 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 196 | assert.Equal(t, res.Stdout(), `name: oci |
| 197 | services: |
| 198 | app: |
| 199 | environment: |
| 200 | HELLO: WORLD |
| 201 | image: alpine |
| 202 | networks: |
| 203 | default: null |
| 204 | networks: |
| 205 | default: |
| 206 | name: oci_default |
| 207 | `) |
| 208 | } |
nothing calls this directly
no test coverage detected