feat:runscope test
This commit is contained in:
@@ -193,3 +193,36 @@ func TestCreateMonitorDecodesTargetFields(t *testing.T) {
|
||||
t.Errorf("Target.Keyword = %q", m.Target.Keyword)
|
||||
}
|
||||
}
|
||||
|
||||
// A runner is a server ID. buildMonitor must refuse one outright rather than
|
||||
// dropping it silently, or a model would believe it had pinned a check to an
|
||||
// agent it never reached.
|
||||
func TestBuildMonitorRefusesRunner(t *testing.T) {
|
||||
args := map[string]any{
|
||||
"name": "api health",
|
||||
"type": "http",
|
||||
"target": map[string]any{"url": "https://example.com"},
|
||||
"runner": "some-server-id",
|
||||
}
|
||||
if _, err := buildMonitor(args); err == nil {
|
||||
t.Fatal("buildMonitor accepted a runner argument")
|
||||
}
|
||||
}
|
||||
|
||||
// Without a runner it still builds, and never arms itself.
|
||||
func TestBuildMonitorWithoutRunnerIsDisabled(t *testing.T) {
|
||||
m, err := buildMonitor(map[string]any{
|
||||
"name": "api health",
|
||||
"type": "http",
|
||||
"target": map[string]any{"url": "https://example.com"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("buildMonitor: %v", err)
|
||||
}
|
||||
if m.Runner != "" {
|
||||
t.Errorf("Runner = %q, want empty so CreateMonitor defaults it to the control plane", m.Runner)
|
||||
}
|
||||
if m.Enabled {
|
||||
t.Error("monitor created enabled")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user