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

Function TestPreprocessProtectedFilesField

pkg/workflow/validation_helpers_test.go:704–804  ·  view source on GitHub ↗

TestPreprocessProtectedFilesField tests the preprocessProtectedFilesField helper.

(t *testing.T)

Source from the content-addressed store, hash-verified

702
703// TestPreprocessProtectedFilesField tests the preprocessProtectedFilesField helper.
704func TestPreprocessProtectedFilesField(t *testing.T) {
705 tests := []struct {
706 name string
707 configData map[string]any
708 wantExclude []string
709 wantPFAfter any // expected value of configData["protected-files"] after preprocessing
710 wantPFPresent bool // whether configData["protected-files"] should exist after preprocessing
711 }{
712 {
713 name: "string form passes through unchanged",
714 configData: map[string]any{"protected-files": "blocked"},
715 wantExclude: nil,
716 wantPFAfter: "blocked",
717 wantPFPresent: true,
718 },
719 {
720 name: "string form allowed passes through unchanged",
721 configData: map[string]any{"protected-files": "allowed"},
722 wantExclude: nil,
723 wantPFAfter: "allowed",
724 wantPFPresent: true,
725 },
726 {
727 name: "object form with policy and exclude",
728 configData: map[string]any{
729 "protected-files": map[string]any{
730 "policy": "fallback-to-issue",
731 "exclude": []any{"AGENTS.md", "CLAUDE.md"},
732 },
733 },
734 wantExclude: []string{"AGENTS.md", "CLAUDE.md"},
735 wantPFAfter: "fallback-to-issue",
736 wantPFPresent: true,
737 },
738 {
739 name: "object form with exclude only (no policy)",
740 configData: map[string]any{
741 "protected-files": map[string]any{
742 "exclude": []any{"AGENTS.md"},
743 },
744 },
745 wantExclude: []string{"AGENTS.md"},
746 wantPFPresent: false, // key removed when no policy
747 },
748 {
749 name: "object form with empty policy string",
750 configData: map[string]any{
751 "protected-files": map[string]any{
752 "policy": "",
753 "exclude": []any{"AGENTS.md"},
754 },
755 },
756 wantExclude: []string{"AGENTS.md"},
757 wantPFPresent: false, // empty policy treated as absent
758 },
759 {
760 name: "nil configData returns nil",
761 configData: nil,

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45

Tested by

no test coverage detected