Added A test case for subset changes of model
This commit is contained in:
		
							parent
							
								
									b4ef04e236
								
							
						
					
					
						commit
						6edb577dc1
					
				
							
								
								
									
										43
									
								
								tests/check_subset_model_change_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								tests/check_subset_model_change_test.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | ||||
| package tests_test | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"testing" | ||||
| ) | ||||
| 
 | ||||
| type Man struct { | ||||
| 	ID  int | ||||
| 	Age int | ||||
| 	Name string | ||||
| } | ||||
| 
 | ||||
| func TestBeforeUpdateStatementChanged(t *testing.T) { | ||||
| 	type TestCase struct { | ||||
| 		BaseObjects Man | ||||
| 		change interface{} | ||||
| 	} | ||||
| 	fmt.Println("Running Eshan Jogwar Test") | ||||
| 	testCases := []TestCase{ | ||||
| 		{ | ||||
| 			BaseObjects: Man{ID: 12231234, Age: 18, Name: "random-name"}, | ||||
| 			change: struct { | ||||
| 				Age int | ||||
| 			}{Age: 20}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			BaseObjects: Man{ID: 12231234, Age: 18, Name: "random-name"}, | ||||
| 			change: struct { | ||||
| 				Age int | ||||
| 				Name string | ||||
| 			}{Age: 20, Name: "another-random-name"}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	for _, test := range testCases { | ||||
| 		// err := test.BaseObjects.update(test.change)
 | ||||
| 		err := DB.Set("data", test.change).Model(test.BaseObjects).Where("id = ?", test.BaseObjects.ID).Updates(test.change).Error | ||||
| 		if err != nil { | ||||
| 			t.Errorf(err.Error()) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 eshan jogwar
						eshan jogwar