diff --git a/.builds/arch.yaml b/.builds/arch.yaml new file mode 100644 index 0000000..17c9d4c --- /dev/null +++ b/.builds/arch.yaml @@ -0,0 +1,9 @@ +image: archlinux +packages: + - dotnet-sdk-6.0 +sources: + - https://git.sr.ht/~cloutier/bird.makeup +tasks: + - test: | + cd bird.makeup/src + dotnet test diff --git a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/Base/PostgresTestingBase.cs b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/Base/PostgresTestingBase.cs index 72bf352..15105e3 100644 --- a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/Base/PostgresTestingBase.cs +++ b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/Base/PostgresTestingBase.cs @@ -14,7 +14,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers.Base { _settings = new PostgresSettings { - ConnString = "Host=127.0.0.1;Username=postgres;Password=mysecretpassword;Database=mytestdb", + ConnString = "Host=127.0.0.1;Username=birdsitelive;Password=birdsitelive;Database=birdsitelive", DbVersionTableName = "DbVersionTableName" + RandomGenerator.GetString(4), CachedTweetsTableName = "CachedTweetsTableName" + RandomGenerator.GetString(4), FollowersTableName = "FollowersTableName" + RandomGenerator.GetString(4), diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs deleted file mode 100644 index 17a3aa2..0000000 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs +++ /dev/null @@ -1,232 +0,0 @@ -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using BirdsiteLive.DAL.Contracts; -using BirdsiteLive.DAL.Models; -using BirdsiteLive.Pipeline.Models; -using BirdsiteLive.Pipeline.Processors; -using BirdsiteLive.Twitter; -using BirdsiteLive.Twitter.Models; -using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace BirdsiteLive.Pipeline.Tests.Processors -{ - [TestClass] - public class RetrieveTweetsProcessorTests - { - [TestMethod] - public async Task ProcessAsync_UserNotSync_Test() - { - #region Stubs - var user1 = new SyncTwitterUser - { - Id = 1, - Acct = "acct", - LastTweetPostedId = -1 - }; - - var user1WtData = new UserWithDataToSync - { - User = user1, - }; - - var users = new[] - { - user1WtData - }; - - var tweets = new[] - { - new ExtractedTweet - { - Id = 47 - } - }; - #endregion - - #region Mocks - var twitterServiceMock = new Mock(MockBehavior.Strict); - twitterServiceMock - .Setup(x => x.GetTimeline( - It.Is(y => y == user1.Acct), - It.Is(y => y == 1), - It.Is(y => y == -1) - )) - .Returns(tweets); - - var twitterUserDalMock = new Mock(MockBehavior.Strict); - twitterUserDalMock - .Setup(x => x.UpdateTwitterUserAsync( - It.Is(y => y == user1.Id), - It.Is(y => y == tweets.Last().Id), - It.Is(y => y == tweets.Last().Id), - It.Is(y => y == 0), - It.IsAny() - )) - .Returns(Task.CompletedTask); - - var twitterUserServiceMock = new Mock(MockBehavior.Strict); - - var logger = new Mock>(MockBehavior.Strict); - #endregion - - var processor = new RetrieveTweetsProcessor(twitterServiceMock.Object, twitterUserDalMock.Object, twitterUserServiceMock.Object, logger.Object); - var usersResult = await processor.ProcessAsync(users, CancellationToken.None); - - #region Validations - twitterServiceMock.VerifyAll(); - twitterUserDalMock.VerifyAll(); - twitterUserServiceMock.VerifyAll(); - logger.VerifyAll(); - - Assert.AreEqual(0, usersResult.Length); - #endregion - } - - [TestMethod] - public async Task ProcessAsync_UserSync_Test() - { - #region Stubs - var user1 = new SyncTwitterUser - { - Id = 1, - Acct = "acct", - LastTweetPostedId = 46, - LastTweetSynchronizedForAllFollowersId = 46 - }; - - var user1WtData = new UserWithDataToSync - { - User = user1, - }; - - var users = new[] - { - user1WtData - }; - - var tweets = new[] - { - new ExtractedTweet - { - Id = 47 - }, - new ExtractedTweet - { - Id = 48 - }, - new ExtractedTweet - { - Id = 49 - } - }; - #endregion - - #region Mocks - var twitterServiceMock = new Mock(MockBehavior.Strict); - twitterServiceMock - .Setup(x => x.GetTimeline( - It.Is(y => y == user1.Acct), - It.Is(y => y == 200), - It.Is(y => y == user1.LastTweetSynchronizedForAllFollowersId) - )) - .Returns(tweets); - - var twitterUserDalMock = new Mock(MockBehavior.Strict); - - var twitterUserServiceMock = new Mock(MockBehavior.Strict); - - var logger = new Mock>(MockBehavior.Strict); - #endregion - - var processor = new RetrieveTweetsProcessor(twitterServiceMock.Object, twitterUserDalMock.Object, twitterUserServiceMock.Object, logger.Object); - var usersResult = await processor.ProcessAsync(users, CancellationToken.None); - - #region Validations - twitterServiceMock.VerifyAll(); - twitterUserDalMock.VerifyAll(); - twitterUserServiceMock.VerifyAll(); - logger.VerifyAll(); - - - Assert.AreEqual(users.Length, usersResult.Length); - Assert.AreEqual(users[0].User.Acct, usersResult[0].User.Acct); - Assert.AreEqual(tweets.Length, usersResult[0].Tweets.Length); - #endregion - } - - [TestMethod] - public async Task ProcessAsync_UserPartiallySync_Test() - { - #region Stubs - var user1 = new SyncTwitterUser - { - Id = 1, - Acct = "acct", - LastTweetPostedId = 49, - LastTweetSynchronizedForAllFollowersId = 46 - }; - - var user1WtData = new UserWithDataToSync - { - User = user1, - }; - - var users = new[] - { - user1WtData - }; - - var tweets = new[] - { - new ExtractedTweet - { - Id = 47 - }, - new ExtractedTweet - { - Id = 48 - }, - new ExtractedTweet - { - Id = 49 - } - }; - #endregion - - #region Mocks - var twitterServiceMock = new Mock(MockBehavior.Strict); - twitterServiceMock - .Setup(x => x.GetTimeline( - It.Is(y => y == user1.Acct), - It.Is(y => y == 200), - It.Is(y => y == user1.LastTweetSynchronizedForAllFollowersId) - )) - .Returns(tweets); - - var twitterUserDalMock = new Mock(MockBehavior.Strict); - - var twitterUserServiceMock = new Mock(MockBehavior.Strict); - - var logger = new Mock>(MockBehavior.Strict); - #endregion - - var processor = new RetrieveTweetsProcessor(twitterServiceMock.Object, twitterUserDalMock.Object, twitterUserServiceMock.Object, logger.Object); - var usersResult = await processor.ProcessAsync(users, CancellationToken.None); - - #region Validations - twitterServiceMock.VerifyAll(); - twitterUserDalMock.VerifyAll(); - twitterUserServiceMock.VerifyAll(); - logger.VerifyAll(); - - Assert.AreEqual(users.Length, usersResult.Length); - Assert.AreEqual(users[0].User.Acct, usersResult[0].User.Acct); - Assert.AreEqual(tweets.Length, usersResult[0].Tweets.Length); - #endregion - } - } -} \ No newline at end of file diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToInboxTaskTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToInboxTaskTests.cs index 367a642..63d41c1 100644 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToInboxTaskTests.cs +++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToInboxTaskTests.cs @@ -65,9 +65,10 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks #region Mocks var activityPubService = new Mock(MockBehavior.Strict); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == noteId), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) @@ -215,9 +216,10 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks #region Mocks var activityPubService = new Mock(MockBehavior.Strict); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == noteId), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) @@ -297,9 +299,10 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks #region Mocks var activityPubService = new Mock(MockBehavior.Strict); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == noteId), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) @@ -376,9 +379,10 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks foreach (var tweetId in new[] { tweetId2, tweetId3 }) { activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == tweetId.ToString()), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) @@ -459,18 +463,20 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks var activityPubService = new Mock(MockBehavior.Strict); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == tweetId2.ToString()), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId2.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) .Returns(Task.CompletedTask); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == tweetId3.ToString()), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId3.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToSharedInboxTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToSharedInboxTests.cs index 7ab06a2..9a8a6db 100644 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToSharedInboxTests.cs +++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToSharedInboxTests.cs @@ -83,9 +83,10 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks #region Mocks var activityPubService = new Mock(MockBehavior.Strict); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == noteId), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) @@ -276,9 +277,10 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks #region Mocks var activityPubService = new Mock(MockBehavior.Strict); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == noteId), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) @@ -379,9 +381,10 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks #region Mocks var activityPubService = new Mock(MockBehavior.Strict); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == noteId), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) @@ -479,9 +482,10 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks foreach (var tweetId in new[] { tweetId2, tweetId3 }) { activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == tweetId.ToString()), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) @@ -583,18 +587,20 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks var activityPubService = new Mock(MockBehavior.Strict); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == tweetId2.ToString()), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId2.ToString()), It.Is(y => y == host), It.Is(y => y == inbox))) .Returns(Task.CompletedTask); activityPubService - .Setup(x => x.PostNewNoteActivity( + .Setup(x => x.PostNewActivity( It.Is(y => y.id == tweetId3.ToString()), It.Is(y => y == twitterHandle), + "Create", It.Is(y => y == tweetId3.ToString()), It.Is(y => y == host), It.Is(y => y == inbox)))