TestMergedFeaturesAreUsedByIsFeatureEnabled verifies that features merged from imports are accessible via isFeatureEnabled function
(t *testing.T)
| 214 | // TestMergedFeaturesAreUsedByIsFeatureEnabled verifies that features merged from imports |
| 215 | // are accessible via isFeatureEnabled function |
| 216 | func 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 |
nothing calls this directly
no test coverage detected