1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-18 21:35:51 -04:00

Starting to add ALTER COLUMN to SQLite.

This commit is contained in:
Keivan Beigi
2013-07-03 18:01:49 -07:00
committed by kay.one
parent 50ee2ee357
commit 1c5a74df98
6 changed files with 151 additions and 4 deletions
@@ -0,0 +1,49 @@
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore.Migration.Framework;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore
{
[TestFixture]
public class SQLiteAlterFixture : DbTest
{
private SQLiteAlter Subject;
[SetUp]
public void SetUp()
{
var connection = Mocker.Resolve<IDatabase>().DataMapper.ConnectionString;
Subject = new SQLiteAlter(connection);
}
[Test]
public void should_parse_existing_columns()
{
var columns = Subject.GetColumns("Series");
columns.Should().NotBeEmpty();
columns.Values.Should().NotContain(c => string.IsNullOrWhiteSpace(c.Name));
columns.Values.Should().NotContain(c => string.IsNullOrWhiteSpace(c.Schema));
}
[Test]
public void should_create_table_from_column_list()
{
var columns = Subject.GetColumns("Series");
columns.Remove("Title");
Subject.CreateTable("Series_New", columns.Values);
var newColumns = Subject.GetColumns("Series_New");
newColumns.Values.Should().HaveSameCount(columns.Values);
newColumns.Should().NotContainKey("Title");
}
}
}
+3 -3
View File
@@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.Framework
var factory = new DbFactory(new MigrationController(new MigrationLogger(TestLogger)), Mocker.GetMock<IAppDirectoryInfo>().Object);
_database = factory.Create(MigrationType);
_db = new TestTestDatabase(_database);
_db = new TestDatabase(_database);
Mocker.SetConstant(_database);
}
@@ -140,12 +140,12 @@ namespace NzbDrone.Core.Test.Framework
void Delete<T>(T childModel) where T : ModelBase, new();
}
public class TestTestDatabase : ITestDatabase
public class TestDatabase : ITestDatabase
{
private readonly IDatabase _dbConnection;
private IMessageAggregator _messageAggregator;
public TestTestDatabase(IDatabase dbConnection)
public TestDatabase(IDatabase dbConnection)
{
_messageAggregator = new Mock<IMessageAggregator>().Object;
_dbConnection = dbConnection;
@@ -124,6 +124,7 @@
<Compile Include="Datastore\PagingSpecExtenstionsTests\ToSortDirectionFixture.cs" />
<Compile Include="Datastore\PagingSpecExtenstionsTests\PagingOffsetFixture.cs" />
<Compile Include="Datastore\ReflectionStrategyFixture\Benchmarks.cs" />
<Compile Include="Datastore\SQLiteAlterFixture.cs" />
<Compile Include="DecisionEngineTests\NotRestrictedNzbSpecificationFixture.cs" />
<Compile Include="Download\DownloadApprovedReportsTests\DownloadApprovedFixture.cs" />
<Compile Include="Download\DownloadApprovedReportsTests\GetQualifiedReportsFixture.cs" />