feat: import agents_and_robots platform as unibots (Matrix-out, unibus transport)
Reemplaza el scaffold del echobot por la plataforma completa de bots traida desde ~/DataProyects/Github/agents_and_robots tras la operacion Matrix-out: los bots ya no hablan por Matrix sino por el bus unibus (modelo todo-rooms + E2E via shell/transportunibus sobre github.com/enmanuel/unibus/pkg/client). - go.mod: replace de unibus -> ../unibus y de fn-registry -> ../../../.. (paths relativos reajustados a la nueva ubicacion dentro de fn_registry). - app.md: bump a 0.2.0, descripcion + arquitectura + comandos + gotchas reales. - modulo Go conservado como github.com/enmanuel/agents (sin reescribir imports). agents_and_robots queda archivado como museo de la era Matrix.
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseArgs_Empty(t *testing.T) {
|
||||
p := ParseArgs(nil)
|
||||
if len(p.Positional) != 0 {
|
||||
t.Errorf("expected 0 positional, got %d", len(p.Positional))
|
||||
}
|
||||
if len(p.Named) != 0 {
|
||||
t.Errorf("expected 0 named, got %d", len(p.Named))
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseArgs_Positional(t *testing.T) {
|
||||
p := ParseArgs([]string{"ssh_command"})
|
||||
if len(p.Positional) != 1 || p.Positional[0] != "ssh_command" {
|
||||
t.Errorf("expected [ssh_command], got %v", p.Positional)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseArgs_Named(t *testing.T) {
|
||||
p := ParseArgs([]string{"host=server1", "command=uptime"})
|
||||
if p.Named["host"] != "server1" {
|
||||
t.Errorf("expected host=server1, got %q", p.Named["host"])
|
||||
}
|
||||
if p.Named["command"] != "uptime" {
|
||||
t.Errorf("expected command=uptime, got %q", p.Named["command"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseArgs_QuotedValue(t *testing.T) {
|
||||
p := ParseArgs([]string{`host=server1`, `command="uptime`, `-a"`})
|
||||
if p.Named["host"] != "server1" {
|
||||
t.Errorf("expected host=server1, got %q", p.Named["host"])
|
||||
}
|
||||
if p.Named["command"] != "uptime -a" {
|
||||
t.Errorf("expected command='uptime -a', got %q", p.Named["command"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseArgs_Mixed(t *testing.T) {
|
||||
p := ParseArgs([]string{"ssh_command", "host=server1", "command=ls"})
|
||||
if len(p.Positional) != 1 || p.Positional[0] != "ssh_command" {
|
||||
t.Errorf("expected positional [ssh_command], got %v", p.Positional)
|
||||
}
|
||||
if p.Named["host"] != "server1" {
|
||||
t.Errorf("expected host=server1, got %q", p.Named["host"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseArgs_SingleQuotes(t *testing.T) {
|
||||
p := ParseArgs([]string{`query='hello`, `world'`})
|
||||
if p.Named["query"] != "hello world" {
|
||||
t.Errorf("expected query='hello world', got %q", p.Named["query"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestArgsToJSON_Empty(t *testing.T) {
|
||||
result := ArgsToJSON(nil)
|
||||
if result != "" {
|
||||
t.Errorf("expected empty string, got %q", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestArgsToJSON_Values(t *testing.T) {
|
||||
result := ArgsToJSON(map[string]string{"host": "server1", "command": "uptime"})
|
||||
if result == "" {
|
||||
t.Error("expected non-empty JSON")
|
||||
}
|
||||
// Should contain both keys
|
||||
if !contains(result, `"host"`) || !contains(result, `"server1"`) {
|
||||
t.Errorf("JSON missing expected keys: %s", result)
|
||||
}
|
||||
}
|
||||
|
||||
func contains(s, sub string) bool {
|
||||
return len(s) >= len(sub) && (s == sub || len(s) > 0 && containsStr(s, sub))
|
||||
}
|
||||
|
||||
func containsStr(s, sub string) bool {
|
||||
for i := 0; i <= len(s)-len(sub); i++ {
|
||||
if s[i:i+len(sub)] == sub {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user