(t *testing.T)
| 87 | } |
| 88 | |
| 89 | func TestIsFeatureEnabledWithData(t *testing.T) { |
| 90 | tests := []struct { |
| 91 | name string |
| 92 | envValue string |
| 93 | frontmatter map[string]any |
| 94 | engineID string |
| 95 | workflowAI string |
| 96 | flag constants.FeatureFlag |
| 97 | expected bool |
| 98 | description string |
| 99 | }{ |
| 100 | { |
| 101 | name: "frontmatter takes precedence - enabled in frontmatter, disabled in env", |
| 102 | envValue: "", |
| 103 | frontmatter: map[string]any{"firewall": true}, |
| 104 | engineID: string(constants.CopilotEngine), |
| 105 | flag: "firewall", |
| 106 | expected: true, |
| 107 | description: "When feature is in frontmatter, it should be enabled regardless of env", |
| 108 | }, |
| 109 | { |
| 110 | name: "frontmatter takes precedence - disabled in frontmatter, enabled in env", |
| 111 | envValue: "firewall", |
| 112 | frontmatter: map[string]any{"firewall": false}, |
| 113 | engineID: string(constants.CopilotEngine), |
| 114 | flag: "firewall", |
| 115 | expected: false, |
| 116 | description: "When feature is explicitly disabled in frontmatter, env should be ignored", |
| 117 | }, |
| 118 | { |
| 119 | name: "fallback to env when not in frontmatter", |
| 120 | envValue: "firewall", |
| 121 | frontmatter: map[string]any{"other-feature": true}, |
| 122 | engineID: string(constants.CopilotEngine), |
| 123 | flag: "firewall", |
| 124 | expected: true, |
| 125 | description: "When feature is not in frontmatter, should check env", |
| 126 | }, |
| 127 | { |
| 128 | name: "disabled when not in frontmatter or env", |
| 129 | envValue: "", |
| 130 | frontmatter: map[string]any{"other-feature": true}, |
| 131 | engineID: string(constants.CopilotEngine), |
| 132 | flag: "firewall", |
| 133 | expected: false, |
| 134 | description: "When feature is in neither frontmatter nor env, should be disabled", |
| 135 | }, |
| 136 | { |
| 137 | name: "case insensitive frontmatter check", |
| 138 | envValue: "", |
| 139 | frontmatter: map[string]any{"FIREWALL": true}, |
| 140 | engineID: string(constants.CopilotEngine), |
| 141 | flag: "firewall", |
| 142 | expected: true, |
| 143 | description: "Frontmatter feature check should be case insensitive", |
| 144 | }, |
| 145 | { |
| 146 | name: "nil frontmatter falls back to env", |
nothing calls this directly
no test coverage detected