Guardrails in the console: attach and detach on a branch, where each applies from, and a column
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
02aac84ca5
commit
d55472c00a
5 files changed
+159
-3
No files matched your search
@@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -17,6 +18,7 @@ import (
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/config"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/control/adminapi"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/control/modelserve"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/guard"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/modelplan"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/promq"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
|
||||
@@ -614,3 +616,36 @@ func TestAWindowsSamplesFillTheChartsWidth(t *testing.T) {
|
||||
t.Errorf("a late start: %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGuardrailsSayWhereTheyApplyFrom(t *testing.T) {
|
||||
var m consoleModel
|
||||
m.people = peopleData{
|
||||
orgs: []orgRow{
|
||||
{level: "org", id: "o1", path: "Acme"},
|
||||
{level: "team", id: "t1", path: "Acme/ml"},
|
||||
{level: "project", id: "p1", path: "Acme/ml/train"},
|
||||
},
|
||||
guardPolicies: []string{"base", "finance", "strict"},
|
||||
guardDefault: []string{"base"},
|
||||
guardAt: []guard.Attachment{
|
||||
{Scope: "team", ScopeID: "t1", Policy: "finance"},
|
||||
{Scope: "project", ScopeID: "p1", Policy: "strict"},
|
||||
},
|
||||
}
|
||||
labels := []string{}
|
||||
for _, it := range m.guardMenu(m.people.orgs[2]).items {
|
||||
labels = append(labels, it.label)
|
||||
}
|
||||
want := []string{"applies from everywhere", "applies from Acme/ml", "✓ strict"}
|
||||
for i, w := range want {
|
||||
if !strings.Contains(labels[i], w) {
|
||||
t.Errorf("%q lacks %q", labels[i], w)
|
||||
}
|
||||
}
|
||||
if c := m.guardCell(m.people.orgs[1]); c != "finance" {
|
||||
t.Errorf("team cell %q", c)
|
||||
}
|
||||
if items := m.orgMenu(m.people.orgs[0]).items; !slices.ContainsFunc(items, func(i menuItem) bool { return i.label == "Guardrails…" }) {
|
||||
t.Error("no Guardrails… in the menu")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user