# Test that a bad docker config file isn't a problem until we actually
# need to talk to a registry.

# Initially the code doesn't use any modules, so there should
# be no need to use a registry.
env DOCKER_CONFIG=$WORK/dockerconfig
exec cue export .
cmp stdout expect-stdout

# The new code uses modules, so we should get a warning
# when the config file is read.
cp OTHER/main.cue main.cue
cp OTHER/cue.mod/module.cue cue.mod/module.cue
! exec cue export .
stderr '^test.org@v0: import failed: cannot find package "example.com/e": cannot fetch example.com/e@v0.0.1: module example.com/e@v0.0.1: cannot do HTTP request: Get ".*": cannot load OCI auth configuration: invalid config file at \$DOCKER_CONFIG: decode failed: .*'
-- dockerconfig/config.json --
should be JSON but isn't
-- expect-stdout --
"ok"
-- main.cue --
package main
"ok"

-- cue.mod/module.cue --
module: "test.org"
language: version: "v0.8.0"

-- OTHER/main.cue --
package main
import "example.com/e"
e.foo

-- OTHER/cue.mod/module.cue --
module: "test.org"
language: version: "v0.8.0"
deps: "example.com/e": v: "v0.0.1"

-- _registry/auth.json --
{"username": "someone", "password": "something"}
-- _registry_prefix --
somewhere/other
-- _registry/example.com_e_v0.0.1/cue.mod/module.cue --
module: "example.com/e@v0"
language: version: "v0.8.0"

-- _registry/example.com_e_v0.0.1/main.cue --
package e

foo: "ok"

