From be71c56eb8afb7cff59e3452fd807fb6d7adda1c Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 8 May 2020 04:10:57 -0400 Subject: [PATCH] Test updates --- .../Controllers/ChatController.cs | 6 +++--- tests/Tgstation.Server.Tests/Instance/ChatTest.cs | 1 + tests/Tgstation.Server.Tests/InstanceManagerTest.cs | 11 +++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ChatController.cs b/src/Tgstation.Server.Host/Controllers/ChatController.cs index 8af345403f..321a004b71 100644 --- a/src/Tgstation.Server.Host/Controllers/ChatController.cs +++ b/src/Tgstation.Server.Host/Controllers/ChatController.cs @@ -87,8 +87,8 @@ namespace Tgstation.Server.Host.Controllers if (countOfExistingBotsInInstance >= Instance.ChatBotLimit.Value) return Conflict(new ErrorMessage(ErrorCode.ChatBotMax)); - model.Enabled = model.Enabled ?? false; - model.ReconnectionInterval = model.ReconnectionInterval ?? 1; + model.Enabled ??= false; + model.ReconnectionInterval ??= 1; // try to update das db first var dbModel = new Models.ChatBot @@ -330,7 +330,7 @@ namespace Tgstation.Server.Host.Controllers return BadRequest(new ErrorMessage(ErrorCode.ChatBotMaxChannels)); if (forCreation) - model.ChannelLimit = model.ChannelLimit ?? (ushort)defaultMaxChannels; + model.ChannelLimit ??= (ushort)defaultMaxChannels; return null; } diff --git a/tests/Tgstation.Server.Tests/Instance/ChatTest.cs b/tests/Tgstation.Server.Tests/Instance/ChatTest.cs index f6a54b595f..a31441d0b8 100644 --- a/tests/Tgstation.Server.Tests/Instance/ChatTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/ChatTest.cs @@ -198,6 +198,7 @@ namespace Tgstation.Server.Tests.Instance await ApiAssert.ThrowsException(() => instanceClient.Update(instance, cancellationToken), ErrorCode.ChatBotMax); discordBot.ChannelLimit = 20; + discordBot.Channels = null; await chatClient.Update(discordBot, cancellationToken); } } diff --git a/tests/Tgstation.Server.Tests/InstanceManagerTest.cs b/tests/Tgstation.Server.Tests/InstanceManagerTest.cs index 3f0012d296..da75591d08 100644 --- a/tests/Tgstation.Server.Tests/InstanceManagerTest.cs +++ b/tests/Tgstation.Server.Tests/InstanceManagerTest.cs @@ -167,11 +167,14 @@ namespace Tgstation.Server.Tests InstanceManagerRights = InstanceManagerRights.SetChatBotLimit }; await usersClient.Update(update, cancellationToken); - firstTest.ChatBotLimit = 77; - var newThing = await instanceManagerClient.Update(firstTest, cancellationToken); - Assert.AreEqual(77, newThing.ChatBotLimit); + var update2 = new Api.Models.Instance + { + Id = firstTest.Id, + ChatBotLimit = 77 + }; + var newThing = await instanceManagerClient.Update(update2, cancellationToken); - update.InstanceManagerRights |= InstanceManagerRights.Delete; + update.InstanceManagerRights |= InstanceManagerRights.Delete | InstanceManagerRights.Create; await usersClient.Update(update, cancellationToken); //but only if the attach file exists