-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove newtonsoft dependency fixes #269 * update dependencies * add possibility to not use capped collection make distributed lock configurable (overridable) * fix unit tests * Add tracing to mongoconnection * update version info * fix unit tests * minor tweak * fix bad inheritance array * Remove regex query Remove regex query for recurring and scheduled optimizations. #272 * fix unit test * update release note and changelog Co-authored-by: Jonas Gottschau <jlg@brandarmies.com>
- Loading branch information
Showing
22 changed files
with
493 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/Hangfire.Mongo.Tests/Migration/Version19MigrationStepFacts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Linq; | ||
using Hangfire.Mongo.Migration; | ||
using Hangfire.Mongo.Migration.Steps.Version19; | ||
using Hangfire.Mongo.Tests.Utils; | ||
using MongoDB.Bson; | ||
using MongoDB.Driver; | ||
using Moq; | ||
using Xunit; | ||
|
||
namespace Hangfire.Mongo.Tests.Migration | ||
{ | ||
public class Version19MigrationStepFacts | ||
{ | ||
private readonly Mock<IMongoMigrationContext> _mongoMigrationBagMock; | ||
private readonly IMongoDatabase _database; | ||
private readonly Random _random; | ||
private readonly AddTypeToSetDto _addTypeToSetDto; | ||
public Version19MigrationStepFacts() | ||
{ | ||
var dbContext = ConnectionUtils.CreateDbContext(); | ||
_database = dbContext.Database; | ||
_mongoMigrationBagMock = new Mock<IMongoMigrationContext>(MockBehavior.Strict); | ||
_random = new Random(); | ||
_addTypeToSetDto = new AddTypeToSetDto(); | ||
} | ||
|
||
[Fact] | ||
public void ExecuteStep01_AddTypeToSetDto_Success() | ||
{ | ||
// ARRANGE | ||
var collection = _database.GetCollection<BsonDocument>("hangfire.jobGraph"); | ||
|
||
collection.Indexes.DropAll(); | ||
collection.InsertMany(new [] | ||
{ | ||
CreateSetDto(), | ||
CreateSetDto(), | ||
CreateSetDto(), | ||
CreateSetDto(), | ||
}); | ||
// ACT | ||
var result = _addTypeToSetDto.Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object); | ||
|
||
// ASSERT | ||
Assert.True(result, "Expected migration to be successful, reported 'false'"); | ||
var migrated = collection.Find(new BsonDocument("_t", "SetDto")).ToList(); | ||
foreach (var doc in migrated) | ||
{ | ||
Assert.True(doc.Contains("SetType")); | ||
} | ||
|
||
var index = collection.Indexes.List().ToList().FirstOrDefault(b => b["name"].AsString == "SetType"); | ||
Assert.NotNull(index); | ||
} | ||
|
||
public BsonDocument CreateSetDto() | ||
{ | ||
var value = _random.Next(123, 234); | ||
return new BsonDocument | ||
{ | ||
["Key"] = $"schedule<{value}>", | ||
["Score"] = (double) _random.Next(12124124, 193435467), | ||
["Value"] = value.ToString(), | ||
["ExpireAt"] = DateTime.UtcNow.AddDays(2), | ||
["_t"] = "SetDto", | ||
["_id"] = ObjectId.GenerateNewId() | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.