mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 00:22:40 +01:00
Fix cases of MultiServerClient not being able to handle GraphQL being disabled
This commit is contained in:
@@ -28,7 +28,7 @@ namespace Tgstation.Server.Tests.Live
|
||||
public ValueTask DisposeAsync()
|
||||
=> ValueTaskExtensions.WhenAll(
|
||||
RestClient.DisposeAsync(),
|
||||
GraphQLClient.DisposeAsync());
|
||||
GraphQLClient?.DisposeAsync() ?? ValueTask.CompletedTask);
|
||||
|
||||
public ValueTask Execute(
|
||||
Func<IRestServerClient, ValueTask> restAction,
|
||||
@@ -48,6 +48,11 @@ namespace Tgstation.Server.Tests.Live
|
||||
where TGraphQLResult : class
|
||||
{
|
||||
var restTask = restAction(RestClient);
|
||||
if (!UseGraphQL)
|
||||
{
|
||||
return (await restTask, null);
|
||||
}
|
||||
|
||||
var graphQLResult = await GraphQLClient.RunOperation(graphQLAction, cancellationToken);
|
||||
|
||||
graphQLResult.EnsureNoErrors();
|
||||
@@ -60,6 +65,6 @@ namespace Tgstation.Server.Tests.Live
|
||||
}
|
||||
|
||||
public ValueTask<IDisposable> Subscribe<TResultData>(Func<IGraphQLClient, IObservable<IOperationResult<TResultData>>> operationExecutor, IObserver<IOperationResult<TResultData>> observer, CancellationToken cancellationToken) where TResultData : class
|
||||
=> GraphQLClient.Subscribe(operationExecutor, observer, cancellationToken);
|
||||
=> GraphQLClient?.Subscribe(operationExecutor, observer, cancellationToken) ?? ValueTask.FromResult<IDisposable>(new CancellationTokenSource());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1930,11 +1930,13 @@ namespace Tgstation.Server.Tests.Live
|
||||
password,
|
||||
cancellationToken: cancellationToken);
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
|
||||
graphQLClientTask = graphQLClientFactory.CreateFromLogin(
|
||||
url,
|
||||
username,
|
||||
password,
|
||||
cancellationToken: cts.Token);
|
||||
graphQLClientTask = MultiServerClient.UseGraphQL
|
||||
? graphQLClientFactory.CreateFromLogin(
|
||||
url,
|
||||
username,
|
||||
password,
|
||||
cancellationToken: cts.Token)
|
||||
: ValueTask.FromResult<IAuthenticatedGraphQLServerClient>(null);
|
||||
|
||||
IRestServerClient restClient;
|
||||
try
|
||||
|
||||
@@ -48,6 +48,9 @@ namespace Tgstation.Server.Tests.Live
|
||||
|
||||
await TestPagination(cancellationToken);
|
||||
|
||||
if (!MultiServerClient.UseGraphQL)
|
||||
return;
|
||||
|
||||
Assert.IsFalse(observer.Completed);
|
||||
Assert.AreEqual(0U, observer.ErrorCount);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user