Fix tests

This commit is contained in:
Jordan Dominion
2025-04-16 19:55:39 -04:00
parent 0f22c3d3ee
commit b2dc94d704
5 changed files with 8 additions and 73 deletions
+4 -1
View File
@@ -4,7 +4,8 @@ Database:
ConnectionString: Data Source=/home/tgstation-server/tgs.sqlite3;Mode=ReadWriteCreate
General:
ConfigVersion: 4.6.0
ApiPort: 5000
ApiEndPoints:
- Port: 5000
GitHubAccessToken:
SetupWizardMode: Never
ByondTopicTimeout: 5000
@@ -19,6 +20,8 @@ General:
UserLimit: 100
UserGroupLimit: 25
ValidInstancePaths:
Session:
BridgePort: 5000
FileLogging:
Directory:
Disable: false
+4 -1
View File
@@ -4,7 +4,8 @@ Database:
ConnectionString: Data Source=/tgs.sqlite3;Mode=ReadWriteCreate
General:
ConfigVersion: 4.6.0
ApiPort: 5000
ApiEndPoints:
- Port: 5000
GitHubAccessToken:
SetupWizardMode: Never
ByondTopicTimeout: 5000
@@ -19,6 +20,8 @@ General:
UserLimit: 100
UserGroupLimit: 25
ValidInstancePaths:
Session:
BridgePort: 5000
FileLogging:
Directory:
Disable: false
@@ -17,9 +17,6 @@ namespace Tgstation.Server.Host.Configuration.Validators
if (options.PrivateKey == null)
return ValidateOptionsResult.Success;
if (options.UpdateRequiredNodeCount == 0)
return ValidateOptionsResult.Fail($"{nameof(SwarmConfiguration.UpdateRequiredNodeCount)} must be greater than 0!");
if (options.Address == null)
return ValidateOptionsResult.Fail($"{nameof(SwarmConfiguration.Address)} must be set to an http endpoint of this swarm service accessible from other servers in the swarm!");
@@ -1,49 +0,0 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
namespace Tgstation.Server.Host.Extensions.Tests
{
[TestClass]
public sealed class TestServiceCollectionExtensions
{
class GoodConfig
{
public const string Section = "asdf";
}
class BadConfig1
{
#pragma warning disable IDE0051 // Remove unused private members
const string Section = "asdf";
#pragma warning restore IDE0051 // Remove unused private members
}
class BadConfig2
{
public const bool Section = false;
}
class BadConfig3
{
//nah
}
[TestMethod]
public void TestUseStandardConfig()
{
var serviceCollection = new ServiceCollection();
var mockConfig = new Mock<IConfigurationSection>();
mockConfig.Setup(x => x.GetSection(It.IsNotNull<string>())).Returns(mockConfig.Object).Verifiable();
Assert.ThrowsException<ArgumentNullException>(() => ServiceCollectionExtensions.UseStandardConfig<GoodConfig>(null, null));
Assert.ThrowsException<ArgumentNullException>(() => serviceCollection.UseStandardConfig<GoodConfig>(null));
serviceCollection.UseStandardConfig<GoodConfig>(mockConfig.Object);
Assert.ThrowsException<InvalidOperationException>(() => serviceCollection.UseStandardConfig<BadConfig1>(mockConfig.Object));
Assert.ThrowsException<InvalidOperationException>(() => serviceCollection.UseStandardConfig<BadConfig2>(mockConfig.Object));
Assert.ThrowsException<InvalidOperationException>(() => serviceCollection.UseStandardConfig<BadConfig3>(mockConfig.Object));
mockConfig.Verify();
}
}
}
@@ -193,8 +193,6 @@ namespace Tgstation.Server.Host.Setup.Tests
//cp config
"y",
"y",
// swarm config
"n",
// telemetry config
"n",
//saved, now for second run
@@ -226,16 +224,6 @@ namespace Tgstation.Server.Host.Setup.Tests
"y",
"n",
String.Empty,
//swarm config
"y",
"node1",
"not a url",
"net.tcp://notandhttpAddress.com",
"http://node1internal:3400",
"http://node1public:3400",
"privatekey",
"n",
"http://controller.com",
// telemetry config
"y",
"telemetry name",
@@ -270,13 +258,6 @@ namespace Tgstation.Server.Host.Setup.Tests
"y",
"n",
"http://fake.com, https://example.org",
//swarm config
"y",
"controller",
"https://controllerinternal.com",
"https://controllerpublic.com",
"privatekey",
"y",
// telemetry config
"n",
};