This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/dagger/dagger_test.go
Andrea Luzzardi cba524eb0f merge Route into Env, rebase dagger compute to use the new API
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2021-03-25 22:29:11 +00:00

57 lines
846 B
Go

package dagger
import (
"testing"
"dagger.io/go/dagger/compiler"
)
func TestLocalDirs(t *testing.T) {
env := mkEnv(t,
`#compute: [
{
do: "local"
dir: "bar"
}
]`,
`dir: #compute: [
{
do: "local"
dir: "foo"
}
]`,
)
dirs := env.LocalDirs()
if len(dirs) != 2 {
t.Fatal(dirs)
}
if _, ok := dirs["foo"]; !ok {
t.Fatal(dirs)
}
if _, ok := dirs["bar"]; !ok {
t.Fatal(dirs)
}
}
func mkEnv(t *testing.T, updater, input string) *Route {
env, err := NewRoute()
if err != nil {
t.Fatal(err)
}
u, err := compiler.Compile("updater.cue", updater)
if err != nil {
t.Fatal(err)
}
if err := env.SetUpdater(u); err != nil {
t.Fatal(err)
}
i, err := compiler.Compile("input.cue", input)
if err != nil {
t.Fatal(err)
}
if err := env.SetInput(i); err != nil {
t.Fatal(err)
}
return env
}