forge-toolkit: хелперы для разработки MCP-серверов на Go. - toolkit: args/schema/result/env/probe/server - toolkit/validate: валидаторы синтаксиса - configreload: live-reload конфига по контент-хэшу - docs: ARCHITECTURE, quickstart, mcp-contract - template/ и examples/hello-tool/ - CI (Gitea Actions), лицензия Apache-2.0
37 lines
896 B
Go
37 lines
896 B
Go
package toolkit
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestExpand(t *testing.T) {
|
|
t.Setenv("TOOLKIT_TEST_VAR", "value")
|
|
got := string(Expand([]byte(`{"x":"${TOOLKIT_TEST_VAR}","y":"static"}`)))
|
|
want := `{"x":"value","y":"static"}`
|
|
if got != want {
|
|
t.Errorf("Expand = %q, want %q", got, want)
|
|
}
|
|
|
|
// Неизвестная переменная → пустая строка (fail-closed далее по валидации).
|
|
os.Unsetenv("TOOLKIT_TEST_MISSING")
|
|
got = string(Expand([]byte(`"${TOOLKIT_TEST_MISSING}"`)))
|
|
if got != `""` {
|
|
t.Errorf("Expand(missing) = %q, want empty", got)
|
|
}
|
|
}
|
|
|
|
func TestHealth(t *testing.T) {
|
|
orig := os.Args
|
|
defer func() { os.Args = orig }()
|
|
|
|
os.Args = []string{"prog", "--health"}
|
|
if !Health() {
|
|
t.Error("Health() = false with --health")
|
|
}
|
|
os.Args = []string{"prog", "-config", "x"}
|
|
if Health() {
|
|
t.Error("Health() = true without --health")
|
|
}
|
|
}
|