mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-11-02 20:02:25 -06:00 
			
		
		
		
	[bugfix] Rework MultiError to wrap + unwrap errors properly (#2057)
* rework multierror a bit * test multierror
This commit is contained in:
		
					parent
					
						
							
								2cee8f2dd8
							
						
					
				
			
			
				commit
				
					
						e8a20f587c
					
				
			
		
					 24 changed files with 263 additions and 154 deletions
				
			
		| 
						 | 
				
			
			@ -22,7 +22,6 @@ import (
 | 
			
		|||
	"crypto/rand"
 | 
			
		||||
	"crypto/rsa"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
| 
						 | 
				
			
			@ -122,16 +121,16 @@ func (suite *SearchGetTestSuite) getSearch(
 | 
			
		|||
		suite.FailNow(err.Error())
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	errs := gtserror.MultiError{}
 | 
			
		||||
	errs := gtserror.NewMultiError(2)
 | 
			
		||||
 | 
			
		||||
	// Check expected code + body.
 | 
			
		||||
	if resultCode := recorder.Code; expectedHTTPStatus != resultCode {
 | 
			
		||||
		errs = append(errs, fmt.Sprintf("expected %d got %d: %v", expectedHTTPStatus, resultCode, ctx.Errors.JSON()))
 | 
			
		||||
		errs.Appendf("expected %d got %d", expectedHTTPStatus, resultCode)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// If we got an expected body, return early.
 | 
			
		||||
	if expectedBody != "" && string(b) != expectedBody {
 | 
			
		||||
		errs = append(errs, fmt.Sprintf("expected %s got %s", expectedBody, string(b)))
 | 
			
		||||
		errs.Appendf("expected %s got %s", expectedBody, string(b))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := errs.Combine(); err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue