memregistry MEMREGISTRY

cd example
exec cue mod mirror -m --to $MEMREGISTRY example.com
cmp stdout $WORK/want-mirror1-stdout

# Check that we can use the mirrored content.
env CUE_REGISTRY=$MEMREGISTRY
exec cue mod tidy
exec cue export
cmp stdout $WORK/want-export-stdout

# Check that if we pass no arguments in --mod mode that
# it copies the dependencies of the current module.
memregistry MEMREGISTRY2
exec cue mod mirror --to $MEMREGISTRY2 --mod
cmp stdout $WORK/want-mirror2-stdout

# No arguments without --mod should fail as a no-op.
! exec cue mod mirror --to $MEMREGISTRY2
! stdout .
cmp stderr $WORK/want-noop-stderr
! exec cue mod mirror
! stdout .
cmp stderr $WORK/want-noop-stderr

-- want-mirror1-stdout --
mirroring baz.org@v0.5.0
mirroring bar.com@v0.5.0
mirroring baz.org@v0.0.2
mirroring bar.com@v0.0.2
mirroring baz.org@v0.10.1
mirroring foo.com/bar/hello@v0.2.3
mirroring example.com@v0.0.1
-- want-mirror2-stdout --
mirroring baz.org@v0.5.0
mirroring bar.com@v0.5.0
mirroring baz.org@v0.10.1
mirroring baz.org@v0.0.2
mirroring bar.com@v0.0.2
mirroring foo.com/bar/hello@v0.2.3
mirroring example.com@v0.0.1
mirroring foo.com/bar/hello@v0.2.3
-- want-export-stdout --
{
    "bar.com@v0": "v0.5.0",
    "baz.org@v0": "v0.10.1",
    "foo.com/bar/hello@v0": "v0.2.3",
    "main": "main",
    "example.com@v0": "v0.0.1"
}
-- want-noop-stderr --
nothing to do; provide arguments or --mod
-- example/cue.mod/module.cue --
module: "main.org"
language: version: "v0.8.0"

// We're depending on a version that's earlier
// then the latest published version.
deps: "example.com@v0": {
	default: true
	v: "v0.0.1"
}
-- example/main.cue --
package main
import "example.com@v0:main"

main
-- _registry/example.com_v0.0.2/cue.mod/module.cue --
module: "example.com@v0"
language: version: "v0.8.0"

-- _registry/example.com_v0.0.2/top.cue --
package main

"example.com@v0": "v0.0.2"

-- _registry/example.com_v0.0.1/cue.mod/module.cue --
module: "example.com@v0"
language: version: "v0.8.0"
deps: {
	"foo.com/bar/hello@v0": v: "v0.2.3"
	"bar.com@v0": v: "v0.5.0"
}

-- _registry/example.com_v0.0.1/top.cue --
package main

import a "foo.com/bar/hello"
a
main: "main"
"example.com@v0": "v0.0.1"

-- _registry/unused.com_v0.2.4/cue.mod/module.cue --
module: "unused.com@v0"
language: version: "v0.8.0"

-- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue --
module: "foo.com/bar/hello@v0"
language: version: "v0.8.0"
deps: {
	"bar.com@v0": v: "v0.0.2"
	"baz.org@v0": v: "v0.10.1"
}

-- _registry/foo.com_bar_hello_v0.2.3/x.cue --
package hello
import (
	a "bar.com/bar@v0"
	b "baz.org@v0:baz"
)
"foo.com/bar/hello@v0": "v0.2.3"
a
b


-- _registry/bar.com_v0.0.2/cue.mod/module.cue --
module: "bar.com@v0"
language: version: "v0.8.0"
deps: "baz.org@v0": v: "v0.0.2"

-- _registry/bar.com_v0.0.2/bar/x.cue --
package bar
import a "baz.org@v0:baz"
"bar.com@v0": "v0.0.2"
a


-- _registry/bar.com_v0.5.0/cue.mod/module.cue --
module: "bar.com@v0"
language: version: "v0.8.0"
deps: "baz.org@v0": v: "v0.5.0"

-- _registry/bar.com_v0.5.0/bar/x.cue --
package bar
import a "baz.org@v0:baz"
"bar.com@v0": "v0.5.0"
a


-- _registry/baz.org_v0.0.2/cue.mod/module.cue --
module: "baz.org@v0"
language: version: "v0.8.0"

-- _registry/baz.org_v0.0.2/baz.cue --
package baz
"baz.org@v0": "v0.0.2"


-- _registry/baz.org_v0.1.2/cue.mod/module.cue --
module: "baz.org@v0"
language: version: "v0.8.0"

-- _registry/baz.org_v0.1.2/baz.cue --
package baz
"baz.org@v0": "v0.1.2"


-- _registry/baz.org_v0.5.0/cue.mod/module.cue --
module: "baz.org@v0"
language: version: "v0.8.0"

-- _registry/baz.org_v0.5.0/baz.cue --
package baz
"baz.org@v0": "v0.5.0"


-- _registry/baz.org_v0.10.1/cue.mod/module.cue --
module: "baz.org@v0"
language: version: "v0.8.0"

-- _registry/baz.org_v0.10.1/baz.cue --
package baz
"baz.org@v0": "v0.10.1"
