bots-garden/mini-mepublic Fork
⑂ v0.9.0
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP
🛟 Updated. ffb1541Unverified · on v0.9.0 · k33g · 13d ago
main_test.go · 42 lines · 1.1 KBGo Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main

import (
	"bytes"
	"testing"

	"mm/internal/config"
	"mm/internal/ui"
)

// The banner says which way yolo is set, both ways.
func TestYoloColumn(t *testing.T) {
	old := config.Cfg.Yolo
	t.Cleanup(func() { config.Cfg.Yolo = old })

	config.Cfg.Yolo = true
	if got := yoloColumn(); got != "yolo: on" {
		t.Errorf("yolo on: %q", got)
	}
	config.Cfg.Yolo = false
	if got := yoloColumn(); got != "yolo: off (tools ask)" {
		t.Errorf("yolo off: %q", got)
	}
}

// A start-up error goes to stderr, never to ui.Out: in `-p` mode stdout is
// the answer, and a script would read "[config error: …]" as one.
func TestStartupErrorsGoToStderr(t *testing.T) {
	var stderr, out bytes.Buffer
	oldErr, oldOut := errOut, ui.Out
	errOut, ui.Out = &stderr, &out
	t.Cleanup(func() { errOut, ui.Out = oldErr, oldOut })

	fail("[config error: %v ]", "open agent.countries.yaml: no such file or directory")

	if out.Len() != 0 {
		t.Errorf("ui.Out got %q, want nothing", out.String())
	}
	if stderr.String() != "[config error: open agent.countries.yaml: no such file or directory ]\n" {
		t.Errorf("stderr got %q", stderr.String())
	}
}