MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_PublicAPI_SetFieldInOnTrigger

Function TestSpec_PublicAPI_SetFieldInOnTrigger

pkg/cli/spec_test.go:408–429  ·  view source on GitHub ↗

TestSpec_PublicAPI_SetFieldInOnTrigger validates the documented on: trigger field update. Spec: "Sets a field inside the on: trigger block"

(t *testing.T)

Source from the content-addressed store, hash-verified

406// TestSpec_PublicAPI_SetFieldInOnTrigger validates the documented on: trigger field update.
407// Spec: "Sets a field inside the on: trigger block"
408func TestSpec_PublicAPI_SetFieldInOnTrigger(t *testing.T) {
409 t.Run("adds on: block when not present", func(t *testing.T) {
410 content := "---\ndescription: my workflow\n---\n\n# Content"
411 result, err := cli.SetFieldInOnTrigger(content, "schedule", "daily")
412 require.NoError(t, err, "SetFieldInOnTrigger should not error when on: block is absent")
413 assert.Contains(t, result, "on:", "result should contain on: block")
414 assert.Contains(t, result, "schedule", "result should contain the new field")
415 })
416
417 t.Run("sets field inside existing on: block", func(t *testing.T) {
418 content := "---\ndescription: my workflow\non:\n push: true\n---\n\n# Content"
419 result, err := cli.SetFieldInOnTrigger(content, "schedule", "daily")
420 require.NoError(t, err, "SetFieldInOnTrigger should not error with existing on: block")
421 assert.Contains(t, result, "schedule", "result should contain the new field in the on: block")
422 })
423
424 t.Run("returns error when no frontmatter found", func(t *testing.T) {
425 content := "# No frontmatter here"
426 _, err := cli.SetFieldInOnTrigger(content, "schedule", "daily")
427 assert.Error(t, err, "SetFieldInOnTrigger should return error when no frontmatter found")
428 })
429}
430
431// TestSpec_PublicAPI_RemoveFieldFromOnTrigger validates the documented on: trigger field removal.
432// Spec: "Removes a field from the on: trigger block"

Callers

nothing calls this directly

Calls 3

SetFieldInOnTriggerFunction · 0.92
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected