mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-28 15:40:56 +01:00
Update integration tests with regressions
This commit is contained in:
@@ -196,6 +196,9 @@ namespace Tgstation.Server.Tests.Instance
|
||||
var instance = metadata.CloneMetadata();
|
||||
instance.ChatBotLimit = 0;
|
||||
await ApiAssert.ThrowsException<ConflictException>(() => instanceClient.Update(instance, cancellationToken), ErrorCode.ChatBotMax);
|
||||
|
||||
discordBot.ChannelLimit = 20;
|
||||
await chatClient.Update(discordBot, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
using Tgstation.Server.Client;
|
||||
using Tgstation.Server.Host.Controllers;
|
||||
using Tgstation.Server.Tests.Instance;
|
||||
@@ -14,13 +15,15 @@ namespace Tgstation.Server.Tests
|
||||
sealed class InstanceManagerTest
|
||||
{
|
||||
readonly IInstanceManagerClient instanceManagerClient;
|
||||
readonly IUsersClient usersClient;
|
||||
readonly string testRootPath;
|
||||
|
||||
long counter;
|
||||
|
||||
public InstanceManagerTest(IInstanceManagerClient instanceManagerClient, string testRootPath)
|
||||
public InstanceManagerTest(IInstanceManagerClient instanceManagerClient, IUsersClient usersClient, string testRootPath)
|
||||
{
|
||||
this.instanceManagerClient = instanceManagerClient ?? throw new ArgumentNullException(nameof(instanceManagerClient));
|
||||
this.usersClient = usersClient ?? throw new ArgumentNullException(nameof(usersClient));
|
||||
this.testRootPath = testRootPath ?? throw new ArgumentNullException(nameof(testRootPath));
|
||||
|
||||
counter = 0;
|
||||
@@ -110,7 +113,7 @@ namespace Tgstation.Server.Tests
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false);
|
||||
} while (firstTest.MoveJob != null);
|
||||
|
||||
|
||||
|
||||
//online it for real for component tests
|
||||
firstTest.Online = true;
|
||||
firstTest.ConfigurationType = ConfigurationType.HostWrite;
|
||||
@@ -152,10 +155,25 @@ namespace Tgstation.Server.Tests
|
||||
var instanceAttachFileName = (string)typeof(InstanceController).GetField("InstanceAttachFileName", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
|
||||
var attachPath = Path.Combine(firstTest.Path, instanceAttachFileName);
|
||||
Assert.IsTrue(File.Exists(attachPath));
|
||||
|
||||
|
||||
//can recreate detached instance
|
||||
firstTest = await instanceManagerClient.CreateOrAttach(firstTest, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Test updating only with SetChatBotLimit works
|
||||
var current = await usersClient.Read(cancellationToken);
|
||||
var update = new UserUpdate
|
||||
{
|
||||
Id = current.Id,
|
||||
InstanceManagerRights = InstanceManagerRights.SetChatBotLimit
|
||||
};
|
||||
await usersClient.Update(update, cancellationToken);
|
||||
firstTest.ChatBotLimit = 77;
|
||||
var newThing = await instanceManagerClient.Update(firstTest, cancellationToken);
|
||||
Assert.AreEqual(77, newThing.ChatBotLimit);
|
||||
|
||||
update.InstanceManagerRights |= InstanceManagerRights.Delete;
|
||||
await usersClient.Update(update, cancellationToken);
|
||||
|
||||
//but only if the attach file exists
|
||||
await instanceManagerClient.Detach(firstTest, cancellationToken).ConfigureAwait(false);
|
||||
File.Delete(attachPath);
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Tgstation.Server.Tests
|
||||
}
|
||||
} while (true);
|
||||
|
||||
var testUpdateVersion = new Version(4, 0, 0, 6);
|
||||
var testUpdateVersion = new Version(4, 1, 0);
|
||||
using (adminClient)
|
||||
//attempt to update to stable
|
||||
await adminClient.Administration.Update(new Administration
|
||||
@@ -142,7 +142,7 @@ namespace Tgstation.Server.Tests
|
||||
Assert.IsTrue(File.Exists(updatedAssemblyPath), "Updated assembly missing!");
|
||||
|
||||
var updatedAssemblyVersion = FileVersionInfo.GetVersionInfo(updatedAssemblyPath);
|
||||
Assert.AreEqual(testUpdateVersion, Version.Parse(updatedAssemblyVersion.FileVersion));
|
||||
Assert.AreEqual(testUpdateVersion, Version.Parse(updatedAssemblyVersion.FileVersion).Semver());
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -220,7 +220,7 @@ namespace Tgstation.Server.Tests
|
||||
|
||||
var adminTest = new AdministrationTest(adminClient.Administration).Run(cancellationToken);
|
||||
var usersTest = new UsersTest(adminClient.Users).Run(cancellationToken);
|
||||
await new InstanceManagerTest(adminClient.Instances, server.Directory).Run(cancellationToken).ConfigureAwait(false);
|
||||
await new InstanceManagerTest(adminClient.Instances, adminClient.Users, server.Directory).Run(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
await adminTest.ConfigureAwait(false);
|
||||
await usersTest.ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user