mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
internal/command: wrap formatted test errors (#596)
This commit is contained in:
parent
69f3c97db7
commit
23ad929d2f
@ -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])
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user