(t *testing.T)
| 237 | } |
| 238 | |
| 239 | func TestGetEffectiveSourcePolicyFile(t *testing.T) { |
| 240 | // Cannot use t.Parallel() since subtests modify environment variables |
| 241 | |
| 242 | tests := []struct { |
| 243 | name string |
| 244 | optionValue string |
| 245 | envValue string |
| 246 | expected string |
| 247 | }{ |
| 248 | { |
| 249 | name: "option value takes precedence over env var", |
| 250 | optionValue: "/path/from/flag.json", |
| 251 | envValue: "/path/from/env.json", |
| 252 | expected: "/path/from/flag.json", |
| 253 | }, |
| 254 | { |
| 255 | name: "env var is used when option is empty", |
| 256 | optionValue: "", |
| 257 | envValue: "/path/from/env.json", |
| 258 | expected: "/path/from/env.json", |
| 259 | }, |
| 260 | { |
| 261 | name: "empty when both are unset", |
| 262 | optionValue: "", |
| 263 | envValue: "", |
| 264 | expected: "", |
| 265 | }, |
| 266 | { |
| 267 | name: "option value used when env var is empty", |
| 268 | optionValue: "/path/from/flag.json", |
| 269 | envValue: "", |
| 270 | expected: "/path/from/flag.json", |
| 271 | }, |
| 272 | } |
| 273 | |
| 274 | for _, tc := range tests { |
| 275 | t.Run(tc.name, func(t *testing.T) { |
| 276 | // Set up the environment variable for this test |
| 277 | t.Setenv("EXPERIMENTAL_BUILDKIT_SOURCE_POLICY", tc.envValue) |
| 278 | |
| 279 | result := GetEffectiveSourcePolicyFile(tc.optionValue) |
| 280 | assert.Equal(t, result, tc.expected) |
| 281 | }) |
| 282 | } |
| 283 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…