internal/command: wrap formatted test errors (#596)

This commit is contained in:
Lars Lehtonen 2023-09-27 01:19:16 -07:00 committed by GitHub
parent 69f3c97db7
commit 23ad929d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -856,7 +856,7 @@ func testLockState(t *testing.T, sourceDir, path string) (func(), error) {
out, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("%s %s", err, out)
return nil, fmt.Errorf("%w %s", err, out)
}
locker := exec.Command(lockBin, path)
@ -881,7 +881,7 @@ func testLockState(t *testing.T, sourceDir, path string) (func(), error) {
buf := make([]byte, 1024)
n, err := pr.Read(buf)
if err != nil {
return deferFunc, fmt.Errorf("read from statelocker returned: %s", err)
return deferFunc, fmt.Errorf("read from statelocker returned: %w", err)
}
output := string(buf[:n])

View File

@ -209,7 +209,7 @@ func (provider *TestProvider) ApplyResourceChange(request providers.ApplyResourc
if !id.IsKnown() {
val, err := uuid.GenerateUUID()
if err != nil {
panic(fmt.Errorf("failed to generate uuid: %v", err))
panic(fmt.Errorf("failed to generate uuid: %w", err))
}
id = cty.StringVal(val)

View File

@ -107,12 +107,12 @@ func (l *MockLauncher) openURL(u string) error {
log.Printf("[DEBUG] webbrowser.MockLauncher: requesting %s", u)
req, err := http.NewRequest("GET", u, nil)
if err != nil {
return fmt.Errorf("failed to construct HTTP request for %s: %s", u, err)
return fmt.Errorf("failed to construct HTTP request for %s: %w", u, err)
}
resp, err := l.Client.Do(req)
if err != nil {
log.Printf("[DEBUG] webbrowser.MockLauncher: request failed: %s", err)
return fmt.Errorf("error requesting %s: %s", u, err)
return fmt.Errorf("error requesting %s: %w", u, err)
}
l.Responses = append(l.Responses, resp)
if resp.StatusCode >= 400 {
@ -135,7 +135,7 @@ func (l *MockLauncher) openURL(u string) error {
oldURL := resp.Request.URL
givenURL, err := url.Parse(u)
if err != nil {
return fmt.Errorf("invalid redirect URL %s: %s", u, err)
return fmt.Errorf("invalid redirect URL %s: %w", u, err)
}
u = oldURL.ResolveReference(givenURL).String()
log.Printf("[DEBUG] webbrowser.MockLauncher: redirected to %s", u)