mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 10:56:10 +01:00 
			
		
		
		
	Move issues related files into models/issues (#19931)
* Move access and repo permission to models/perm/access * fix test * fix git test * Move functions sequence * Some improvements per @KN4CK3R and @delvh * Move issues related code to models/issues * Move some issues related sub package * Merge * Fix test * Fix test * Fix test * Fix test * Rename some files
This commit is contained in:
		| @@ -228,3 +228,46 @@ func TestGetFeedsCorrupted(t *testing.T) { | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.Len(t, actions, 0) | ||||
| } | ||||
|  | ||||
| func TestConsistencyUpdateAction(t *testing.T) { | ||||
| 	if !setting.Database.UseSQLite3 { | ||||
| 		t.Skip("Test is only for SQLite database.") | ||||
| 	} | ||||
| 	assert.NoError(t, unittest.PrepareTestDatabase()) | ||||
| 	id := 8 | ||||
| 	unittest.AssertExistsAndLoadBean(t, &Action{ | ||||
| 		ID: int64(id), | ||||
| 	}) | ||||
| 	_, err := db.GetEngine(db.DefaultContext).Exec(`UPDATE action SET created_unix = "" WHERE id = ?`, id) | ||||
| 	assert.NoError(t, err) | ||||
| 	actions := make([]*Action, 0, 1) | ||||
| 	// | ||||
| 	// XORM returns an error when created_unix is a string | ||||
| 	// | ||||
| 	err = db.GetEngine(db.DefaultContext).Where("id = ?", id).Find(&actions) | ||||
| 	if assert.Error(t, err) { | ||||
| 		assert.Contains(t, err.Error(), "type string to a int64: invalid syntax") | ||||
| 	} | ||||
| 	// | ||||
| 	// Get rid of incorrectly set created_unix | ||||
| 	// | ||||
| 	count, err := CountActionCreatedUnixString() | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.EqualValues(t, 1, count) | ||||
| 	count, err = FixActionCreatedUnixString() | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.EqualValues(t, 1, count) | ||||
|  | ||||
| 	count, err = CountActionCreatedUnixString() | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.EqualValues(t, 0, count) | ||||
| 	count, err = FixActionCreatedUnixString() | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.EqualValues(t, 0, count) | ||||
|  | ||||
| 	// | ||||
| 	// XORM must be happy now | ||||
| 	// | ||||
| 	assert.NoError(t, db.GetEngine(db.DefaultContext).Where("id = ?", id).Find(&actions)) | ||||
| 	unittest.CheckConsistencyFor(t, &Action{}) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user