TestValidateFeatureConfig tests feature flag and action-mode validation.
(t *testing.T)
| 69 | |
| 70 | // TestValidateFeatureConfig tests feature flag and action-mode validation. |
| 71 | func TestValidateFeatureConfig(t *testing.T) { |
| 72 | tests := []struct { |
| 73 | name string |
| 74 | features map[string]any |
| 75 | shouldError bool |
| 76 | errorContains string |
| 77 | }{ |
| 78 | { |
| 79 | name: "no features", |
| 80 | features: nil, |
| 81 | shouldError: false, |
| 82 | }, |
| 83 | { |
| 84 | name: "valid action-mode dev", |
| 85 | features: map[string]any{ |
| 86 | "action-mode": "dev", |
| 87 | }, |
| 88 | shouldError: false, |
| 89 | }, |
| 90 | { |
| 91 | name: "valid action-mode release", |
| 92 | features: map[string]any{ |
| 93 | "action-mode": "release", |
| 94 | }, |
| 95 | shouldError: false, |
| 96 | }, |
| 97 | { |
| 98 | name: "invalid action-mode", |
| 99 | features: map[string]any{ |
| 100 | "action-mode": "invalid-mode", |
| 101 | }, |
| 102 | shouldError: true, |
| 103 | errorContains: "invalid action-mode feature flag", |
| 104 | }, |
| 105 | { |
| 106 | name: "empty action-mode is ignored", |
| 107 | features: map[string]any{ |
| 108 | "action-mode": "", |
| 109 | }, |
| 110 | shouldError: false, |
| 111 | }, |
| 112 | } |
| 113 | |
| 114 | for _, tt := range tests { |
| 115 | t.Run(tt.name, func(t *testing.T) { |
| 116 | tmpDir := testutil.TempDir(t, "feature-test") |
| 117 | markdownPath := filepath.Join(tmpDir, "test.md") |
| 118 | |
| 119 | compiler := NewCompiler() |
| 120 | workflowData := &WorkflowData{ |
| 121 | Name: "Test", |
| 122 | MarkdownContent: "# Test", |
| 123 | AI: "copilot", |
| 124 | Features: tt.features, |
| 125 | } |
| 126 | |
| 127 | err := compiler.validateFeatureConfig(workflowData, markdownPath) |
| 128 | if tt.shouldError { |
nothing calls this directly
no test coverage detected