added db migration + test
This commit is contained in:
parent
6f8a2c0373
commit
4157f613ea
2 changed files with 32 additions and 0 deletions
|
@ -180,6 +180,9 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
|
|||
|
||||
var addMovedToAcct = $@"ALTER TABLE {_settings.TwitterUserTableName} ADD movedToAcct VARCHAR(305)";
|
||||
await _tools.ExecuteRequestAsync(addMovedToAcct);
|
||||
|
||||
var addDeletedToAcct = $@"ALTER TABLE {_settings.TwitterUserTableName} ADD deleted BOOLEAN";
|
||||
await _tools.ExecuteRequestAsync(addDeletedToAcct);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -153,6 +153,35 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers
|
|||
Assert.AreEqual(movedToAcct, result.MovedToAcct);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task CreateUpdateAndGetDeletedUser()
|
||||
{
|
||||
var acct = "myid";
|
||||
var lastTweetId = 1548L;
|
||||
|
||||
var dal = new TwitterUserPostgresDal(_settings);
|
||||
|
||||
await dal.CreateTwitterUserAsync(acct, lastTweetId);
|
||||
var result = await dal.GetTwitterUserAsync(acct);
|
||||
|
||||
var updatedLastTweetId = 1600L;
|
||||
var updatedLastSyncId = 1550L;
|
||||
var now = DateTime.Now;
|
||||
var errors = 15;
|
||||
await dal.UpdateTwitterUserAsync(result.Id, updatedLastTweetId, updatedLastSyncId, errors, now, null, null, true);
|
||||
|
||||
result = await dal.GetTwitterUserAsync(acct);
|
||||
|
||||
Assert.AreEqual(acct, result.Acct);
|
||||
Assert.AreEqual(updatedLastTweetId, result.LastTweetPostedId);
|
||||
Assert.AreEqual(updatedLastSyncId, result.LastTweetSynchronizedForAllFollowersId);
|
||||
Assert.AreEqual(errors, result.FetchingErrorCount);
|
||||
Assert.IsTrue(Math.Abs((now.ToUniversalTime() - result.LastSync).Milliseconds) < 100);
|
||||
Assert.AreEqual(null, result.MovedTo);
|
||||
Assert.AreEqual(null, result.MovedToAcct);
|
||||
Assert.AreEqual(true, result.Deleted);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task CreateUpdate2AndGetUser()
|
||||
{
|
||||
|
|
Reference in a new issue