mirror of
				https://github.com/chaisql/chai.git
				synced 2025-11-01 03:12:38 +08:00 
			
		
		
		
	Refactor to handle errors with internal/errors (#432)
All new error handling code now rely on internal/errors package which provides a compilation time toggle that enables to capture stacktraces for easier debugging while developing. It also comes with a new testutil/assert package which replaces the require package when it comes to checking or comparing errors and printing the stack traces if needed. Finally, the test target of the Makefile uses the debug build tag by default. A testnodebug target is also provided for convenience and to make sure no tests are broken due to not having used the internal/errors or testutil/assert package. See #431 for more details
This commit is contained in:
		 Jean Hadrien Chabran
					Jean Hadrien Chabran
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							56025724c3
						
					
				
				
					commit
					4a6e68439a
				
			| @@ -7,6 +7,7 @@ import ( | ||||
| 	"github.com/genjidb/genji/internal/query/statement" | ||||
| 	"github.com/genjidb/genji/internal/sql/parser" | ||||
| 	"github.com/genjidb/genji/internal/stream" | ||||
| 	"github.com/genjidb/genji/internal/testutil/assert" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| @@ -28,10 +29,10 @@ func TestParserExplain(t *testing.T) { | ||||
| 		t.Run(test.name, func(t *testing.T) { | ||||
| 			q, err := parser.ParseQuery(test.s) | ||||
| 			if test.errored { | ||||
| 				require.Error(t, err) | ||||
| 				assert.Error(t, err) | ||||
| 				return | ||||
| 			} | ||||
| 			require.NoError(t, err) | ||||
| 			assert.NoError(t, err) | ||||
| 			require.Len(t, q.Statements, 1) | ||||
| 			require.EqualValues(t, test.expected, q.Statements[0]) | ||||
| 		}) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user