warnPolicyError emits to the supplied writer when err is non-nil and stays silent for nil. Verifies the build.go fail-open behaviour can be observed by users.
(t *testing.T)
| 253 | // stays silent for nil. Verifies the build.go fail-open behaviour can be |
| 254 | // observed by users. |
| 255 | func TestWarnPolicyError(t *testing.T) { |
| 256 | var buf bytes.Buffer |
| 257 | warnPolicyError(&buf, nil) |
| 258 | if buf.Len() != 0 { |
| 259 | t.Fatalf("warnPolicyError with nil err should write nothing, got %q", buf.String()) |
| 260 | } |
| 261 | |
| 262 | buf.Reset() |
| 263 | warnPolicyError(&buf, errors.New("boom")) |
| 264 | if buf.String() != "warning: user policy not applied: boom\n" { |
| 265 | t.Fatalf("warnPolicyError output = %q", buf.String()) |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | // End-to-end through buildInternal: when a valid policy.yml exists in |
| 270 | // HOME, building the real command tree applies pruning to it. This is |
nothing calls this directly
no test coverage detected