Started reworking skaldctl. Give room status along with room name.

This commit is contained in:
Storm Dragon
2026-05-30 22:46:32 -04:00
parent 4f35f4b933
commit 26c7808587
15 changed files with 639 additions and 556 deletions
+351 -522
View File
File diff suppressed because it is too large Load Diff
+55
View File
@@ -1,7 +1,10 @@
package main
import (
"bufio"
"bytes"
"encoding/json"
"strings"
"testing"
"git.stormux.org/storm/skald/hall"
@@ -40,6 +43,58 @@ func TestMakePassword(t *testing.T) {
}
}
func TestInteractiveHall(t *testing.T) {
input := strings.NewReader(strings.Join([]string{
"city-watch",
"City Watch",
"An audio hall",
"yes",
"",
"",
"no",
"no",
"vetinari",
"",
"yes",
"",
}, "\n"))
passwords := []string{"secret", "secret", "guest", "guest"}
readPassword := func(string) (string, error) {
password := passwords[0]
passwords = passwords[1:]
return password, nil
}
var output bytes.Buffer
name, desc, err := interactiveHall(
bufio.NewReader(input), &output, readPassword, "",
)
if err != nil {
t.Fatalf("interactiveHall: %v", err)
}
if name != "city-watch" {
t.Fatalf("name = %q", name)
}
if desc.DisplayName != "City Watch" || desc.Description != "An audio hall" {
t.Fatalf("description = %#v", desc)
}
if !desc.Public || !desc.AllowRecording || !desc.Autolock {
t.Fatalf("common settings = %#v", desc)
}
user := desc.Users["vetinari"]
if ok, err := user.Password.Match("secret"); !ok || err != nil {
t.Fatalf("operator password match = %v, %v", ok, err)
}
if user.Permissions.String() != "op" {
t.Fatalf("operator permissions = %v", user.Permissions)
}
if desc.WildcardUser == nil {
t.Fatal("wildcard user is nil")
}
if ok, err := desc.WildcardUser.Password.Match("guest"); !ok || err != nil {
t.Fatalf("wildcard password match = %v, %v", ok, err)
}
}
func TestFormatPermissions(t *testing.T) {
tests := []struct{ j, v, p string }{
{`"op"`, "op", "[cmopt]"},