# Check that we can use the cue mod publish command to publish to a registry
# that's protected by authorization.

memregistry -auth=foo:bar MEMREGISTRY
env CUE_REGISTRY=$MEMREGISTRY+insecure
env DOCKER_CONFIG=$WORK/dockerconfig
env-fill $DOCKER_CONFIG/config.json

cd example
exec cue mod publish v0.0.1
stdout '^published example.com@v0.0.1 to [^ ]+/example.com:v0.0.1$'
cd ../main
exec cue eval .
cmp stdout ../expect-eval-stdout

-- dockerconfig/config.json --
{
	"auths": {
		"${MEMREGISTRY}": {
			"username": "foo",
			"password": "bar"
		}
	}
}

-- expect-eval-stdout --
"example.com@v0": "v0.0.1"
main:             "main"
-- main/cue.mod/module.cue --
module: "main.org"
language: version: "v0.9.0-alpha.0"
deps: "example.com@v0": v: "v0.0.1"

-- main/main.cue --
package main
import "example.com@v0:main"

main
"main": "main"

-- example/cue.mod/module.cue --
module: "example.com@v0"
language: version: "v0.9.0-alpha.0"

source: kind: "self"

-- example/top.cue --
package main

"example.com@v0": "v0.0.1"
