This repository has been archived on 2026-11-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
w10k/main_test.go
T
unkin-agent 5b696fc572
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
Keep aliases of collided envs and align aliases even when the target fails
2026-11-08 21:42:09 +11:00

41 lines
1.1 KiB
Go

package main
import (
"bytes"
"os"
"path/filepath"
"testing"
)
func TestListShowsAliasRows(t *testing.T) {
root := t.TempDir()
cache, base := filepath.Join(root, "cache"), filepath.Join(root, "code")
wt := filepath.Join(cache, "worktrees", "unkin", "abc123-0123456789ab")
for _, d := range []string{wt, base} {
if err := os.MkdirAll(d, 0o755); err != nil {
t.Fatal(err)
}
}
for _, e := range []string{"develop", "production"} {
if err := os.Symlink(wt, filepath.Join(base, e)); err != nil {
t.Fatal(err)
}
}
cfg := filepath.Join(root, "r10k.yaml")
y := "cachedir: " + cache + "\nw10k: {aliases: {production: develop}}\nsources: {unkin: {remote: r, basedir: " + base + "}}\n"
if err := os.WriteFile(cfg, []byte(y), 0o644); err != nil {
t.Fatal(err)
}
var out bytes.Buffer
cmd := rootCmd()
cmd.SetOut(&out)
cmd.SetArgs([]string{"-c", cfg, "list"})
if err := cmd.Execute(); err != nil {
t.Fatal(err)
}
want := "unkin\tdevelop\tabc123\nunkin\tproduction\tabc123\talias of develop\n"
if out.String() != want {
t.Fatalf("list:\n%q\nwant\n%q", out.String(), want)
}
}