feat(cli): proxdeploy in Go
Befehle login, servers, distros, profiles, presets, vm, lxc, template list|build, batch, status, logs --follow, cancel. Renderer im Aufbau der Vorgabe (zeichengenau per Golden-File), 24-bit/256/ohne Farbe, --ascii, --quiet, --json, --dry-run; live im Terminal, zeilenweise ohne. SSE mit Wiederverbinden und Polling als Rückfall. Typen aus openapi.json per oapi-codegen; Release-Builds per cli/bauen.sh. Refs #013 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package konfig
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWaehlenUndUmgebung(t *testing.T) {
|
||||
pfad := filepath.Join(t.TempDir(), "proxdeploy", "config.toml")
|
||||
t.Setenv("PROXDEPLOY_CONFIG", pfad)
|
||||
t.Setenv("PROXDEPLOY_URL", "")
|
||||
t.Setenv("PROXDEPLOY_TOKEN", "")
|
||||
t.Setenv("PROXDEPLOY_INSTANCE", "")
|
||||
|
||||
var d Datei
|
||||
d.Setzen("", Instanz{URL: "https://a", Token: "pd_a", Server: "rz1"})
|
||||
d.Setzen("labor", Instanz{URL: "https://b", Token: "pd_b"})
|
||||
if err := Schreiben(pfad, d); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if info, _ := os.Stat(pfad); info.Mode().Perm() != 0o600 {
|
||||
t.Errorf("Rechte %v", info.Mode().Perm())
|
||||
}
|
||||
gelesen, _, err := Lesen()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if i, _ := gelesen.Waehlen(""); i.URL != "https://a" || i.Server != "rz1" {
|
||||
t.Errorf("Hauptabschnitt: %+v", i)
|
||||
}
|
||||
if i, _ := gelesen.Waehlen("labor"); i.Token != "pd_b" {
|
||||
t.Errorf("labor: %+v", i)
|
||||
}
|
||||
if _, err := gelesen.Waehlen("gibtsnicht"); err == nil {
|
||||
t.Error("unbekannte Instanz ohne Fehler")
|
||||
}
|
||||
t.Setenv("PROXDEPLOY_INSTANCE", "labor")
|
||||
t.Setenv("PROXDEPLOY_TOKEN", "pd_env")
|
||||
if i, _ := gelesen.Waehlen(""); i.URL != "https://b" || i.Token != "pd_env" {
|
||||
t.Errorf("Umgebung: %+v", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLesenOhneDatei(t *testing.T) {
|
||||
t.Setenv("PROXDEPLOY_CONFIG", filepath.Join(t.TempDir(), "fehlt.toml"))
|
||||
d, _, err := Lesen()
|
||||
if err != nil || d.URL != "" {
|
||||
t.Errorf("%v %+v", err, d)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user