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

Function TestMergedFeaturesAreUsedByIsFeatureEnabled

pkg/workflow/features_test.go:216–268  ·  view source on GitHub ↗

TestMergedFeaturesAreUsedByIsFeatureEnabled verifies that features merged from imports are accessible via isFeatureEnabled function

(t *testing.T)

Source from the content-addressed store, hash-verified

214// TestMergedFeaturesAreUsedByIsFeatureEnabled verifies that features merged from imports
215// are accessible via isFeatureEnabled function
216func TestMergedFeaturesAreUsedByIsFeatureEnabled(t *testing.T) {
217 // Create workflow data with merged features (simulating the result of merging imports)
218 workflowData := &WorkflowData{
219 Features: map[string]any{
220 "imported-feature": true,
221 "another-feature": false,
222 "string-feature": "enabled",
223 "top-level-feature": true,
224 },
225 }
226
227 // Test that imported features are accessible via isFeatureEnabled
228 tests := []struct {
229 name string
230 flag constants.FeatureFlag
231 expected bool
232 }{
233 {
234 name: "imported feature enabled",
235 flag: "imported-feature",
236 expected: true,
237 },
238 {
239 name: "imported feature disabled",
240 flag: "another-feature",
241 expected: false,
242 },
243 {
244 name: "string feature treated as enabled",
245 flag: "string-feature",
246 expected: true,
247 },
248 {
249 name: "top-level feature enabled",
250 flag: "top-level-feature",
251 expected: true,
252 },
253 {
254 name: "non-existent feature",
255 flag: "non-existent",
256 expected: false,
257 },
258 }
259
260 for _, tt := range tests {
261 t.Run(tt.name, func(t *testing.T) {
262 result := isFeatureEnabled(tt.flag, workflowData)
263 if result != tt.expected {
264 t.Errorf("isFeatureEnabled(%q) = %v, want %v", tt.flag, result, tt.expected)
265 }
266 })
267 }
268}
269
270// TestMergedFeaturesTopLevelPrecedence verifies that top-level features take precedence
271// over imported features in the merged features map

Callers

nothing calls this directly

Calls 3

isFeatureEnabledFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected