Test updates

This commit is contained in:
Jordan Brown
2020-05-08 04:10:57 -04:00
parent 7de1c45aa8
commit be71c56eb8
3 changed files with 11 additions and 7 deletions
@@ -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;
}
@@ -198,6 +198,7 @@ namespace Tgstation.Server.Tests.Instance
await ApiAssert.ThrowsException<ConflictException>(() => instanceClient.Update(instance, cancellationToken), ErrorCode.ChatBotMax);
discordBot.ChannelLimit = 20;
discordBot.Channels = null;
await chatClient.Update(discordBot, cancellationToken);
}
}
@@ -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