bf9395e022
CI / results (push) Blocked by required conditions
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / e2e-live (push) Waiting to run
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / deadcode (push) Waiting to run
63 lines
1.4 KiB
Go
63 lines
1.4 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package core
|
|
|
|
import "testing"
|
|
|
|
func TestStrictMode_IsActive(t *testing.T) {
|
|
tests := []struct {
|
|
mode StrictMode
|
|
active bool
|
|
}{
|
|
{StrictModeOff, false},
|
|
{"", false},
|
|
{StrictModeBot, true},
|
|
{StrictModeUser, true},
|
|
}
|
|
for _, tt := range tests {
|
|
if got := tt.mode.IsActive(); got != tt.active {
|
|
t.Errorf("StrictMode(%q).IsActive() = %v, want %v", tt.mode, got, tt.active)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestStrictMode_AllowsIdentity(t *testing.T) {
|
|
tests := []struct {
|
|
mode StrictMode
|
|
id Identity
|
|
ok bool
|
|
}{
|
|
{StrictModeOff, AsUser, true},
|
|
{StrictModeOff, AsBot, true},
|
|
{StrictModeBot, AsBot, true},
|
|
{StrictModeBot, AsUser, false},
|
|
{StrictModeUser, AsUser, true},
|
|
{StrictModeUser, AsBot, false},
|
|
{"", AsUser, true},
|
|
{"", AsBot, true},
|
|
}
|
|
for _, tt := range tests {
|
|
if got := tt.mode.AllowsIdentity(tt.id); got != tt.ok {
|
|
t.Errorf("StrictMode(%q).AllowsIdentity(%q) = %v, want %v", tt.mode, tt.id, got, tt.ok)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestStrictMode_ForcedIdentity(t *testing.T) {
|
|
tests := []struct {
|
|
mode StrictMode
|
|
want Identity
|
|
}{
|
|
{StrictModeOff, ""},
|
|
{StrictModeBot, AsBot},
|
|
{StrictModeUser, AsUser},
|
|
{"", ""},
|
|
}
|
|
for _, tt := range tests {
|
|
if got := tt.mode.ForcedIdentity(); got != tt.want {
|
|
t.Errorf("StrictMode(%q).ForcedIdentity() = %q, want %q", tt.mode, got, tt.want)
|
|
}
|
|
}
|
|
}
|