skip sql server
This commit is contained in:
		
							parent
							
								
									23c65aaf3d
								
							
						
					
					
						commit
						fba5580bb9
					
				| @ -554,6 +554,9 @@ func (m ConnPoolLastInsertIDMock) ExecContext(ctx context.Context, query string, | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func TestCreateWithDisableLastInsertID(t *testing.T) { | func TestCreateWithDisableLastInsertID(t *testing.T) { | ||||||
|  | 	if isSQLServer() { | ||||||
|  | 		t.Skip("SQLServer driver doesn't use default create hook in gorm") | ||||||
|  | 	} | ||||||
| 	mockCreateSupportReturning := func() func() { | 	mockCreateSupportReturning := func() func() { | ||||||
| 		revertCreateSupportReturning := func() { | 		revertCreateSupportReturning := func() { | ||||||
| 			os.Setenv("GORM_E2E_TEST_MOCK_CREATE_RETURNING", "") | 			os.Setenv("GORM_E2E_TEST_MOCK_CREATE_RETURNING", "") | ||||||
| @ -577,8 +580,8 @@ func TestCreateWithDisableLastInsertID(t *testing.T) { | |||||||
| 	defer mockCreateSupportReturning()() | 	defer mockCreateSupportReturning()() | ||||||
| 	defer mockConnPoolExec()() | 	defer mockConnPoolExec()() | ||||||
| 
 | 
 | ||||||
| 	user := &User{Name: "TestCreateWithDisableLastInsertID"} | 	user := GetUser("TestCreateWithDisableLastInsertID0", Config{}) | ||||||
| 	err := DB.Create(&user).Error | 	err := DB.Create(user).Error | ||||||
| 	if DB.RowsAffected > 0 && err == nil { | 	if DB.RowsAffected > 0 && err == nil { | ||||||
| 		t.Fatalf("it should be error") | 		t.Fatalf("it should be error") | ||||||
| 	} | 	} | ||||||
| @ -587,7 +590,8 @@ func TestCreateWithDisableLastInsertID(t *testing.T) { | |||||||
| 	defer func() { | 	defer func() { | ||||||
| 		DB.DisableLastInsertID = false | 		DB.DisableLastInsertID = false | ||||||
| 	}() | 	}() | ||||||
| 	err = DB.Create(&user).Error | 
 | ||||||
|  | 	err = DB.Create(user).Error | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("it should be nil, got %v", err) | 		t.Fatalf("it should be nil, got %v", err) | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -9,7 +9,6 @@ import ( | |||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"gorm.io/gorm" | 	"gorm.io/gorm" | ||||||
| 
 |  | ||||||
| 	. "gorm.io/gorm/utils/tests" | 	. "gorm.io/gorm/utils/tests" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| @ -285,6 +284,10 @@ func isSqlite() bool { | |||||||
| 	return os.Getenv("GORM_DIALECT") == "sqlite" | 	return os.Getenv("GORM_DIALECT") == "sqlite" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func isSQLServer() bool { | ||||||
|  | 	return os.Getenv("GORM_DIALECT") == "sqlserver" | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func db(unscoped bool) *gorm.DB { | func db(unscoped bool) *gorm.DB { | ||||||
| 	if unscoped { | 	if unscoped { | ||||||
| 		return DB.Unscoped() | 		return DB.Unscoped() | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Krisdiano
						Krisdiano