Skip to content

Commit

Permalink
Fix code generator
Browse files Browse the repository at this point in the history
Code generator was failing due to a change in how the swagger put
params are defined.
grpc-ecosystem/grpc-gateway#201
Fix a few failing tests.
  • Loading branch information
sesposito committed Nov 10, 2022
1 parent a1be41d commit 9e46121
Show file tree
Hide file tree
Showing 10 changed files with 375 additions and 238 deletions.
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/tests/Nakama.Tests/bin/Debug/net5.0/Nakama.Tests.dll",
"args": [],
"cwd": "${workspaceFolder}/tests/Nakama.Tests",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "integratedTerminal",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
42 changes: 42 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/tests/Nakama.Tests/Nakama.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/tests/Nakama.Tests/Nakama.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/tests/Nakama.Tests/Nakama.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
6 changes: 5 additions & 1 deletion Nakama.Tests/HttpErrorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* limitations under the License.
*/

using System.Collections.Generic;
using Nakama.TinyJson;

namespace Nakama.Tests.Api
{
using System;
Expand Down Expand Up @@ -46,7 +49,8 @@ public async Task BadLuaRpcReturnsErrorMessageAndDict()
await Assert.ThrowsAsync<ApiResponseException>(() => _client.RpcAsync(session, funcid));
Assert.NotNull(exception.Message);
Assert.NotEmpty(exception.Message);
Assert.Equal("Some error occured.", exception.Message);
var decoded = exception.Message.FromJson<Dictionary<string, object>>();
Assert.Equal("Some error occured.", decoded["message"]);
}

[Fact(Skip = "requires go plugin")]
Expand Down
4 changes: 2 additions & 2 deletions Nakama.Tests/LinkUnlinkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public async Task ShouldNotUnlinkSteam()
var session = await _client.AuthenticateCustomAsync(customid);

var ex = await Assert.ThrowsAsync<ApiResponseException>(() => _client.UnlinkSteamAsync(session, "invalid"));
Assert.Equal((int) HttpStatusCode.BadRequest, ex.StatusCode);
Assert.Equal((int) HttpStatusCode.Unauthorized, ex.StatusCode);
}

[Fact(Timeout = TestsUtil.TIMEOUT_MILLISECONDS)]
Expand All @@ -411,7 +411,7 @@ public async Task ShouldNotUnlinkApple()
var session = await _client.AuthenticateCustomAsync(customid);

var ex = await Assert.ThrowsAsync<ApiResponseException>(() => _client.UnlinkAppleAsync(session, "invalid"));
Assert.Equal((int) HttpStatusCode.BadRequest, ex.StatusCode);
Assert.Equal((int) HttpStatusCode.Unauthorized, ex.StatusCode);
}
}
}
1 change: 0 additions & 1 deletion Nakama.Tests/RpcTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class RpcTest
public RpcTest()
{
_client = TestsUtil.FromSettingsFile();

}

[Fact(Timeout = TestsUtil.TIMEOUT_MILLISECONDS)]
Expand Down
2 changes: 2 additions & 0 deletions Nakama.Tests/Socket/WebSocketTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

using System;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -65,6 +66,7 @@ public async Task ShouldCreateSocketAndDisconnect()
_socket.Closed += () => completer.SetResult(true);

await _socket.ConnectAsync(session);
await Task.Delay(1000);
await _socket.CloseAsync();

Assert.True(await completer.Task);
Expand Down
Loading

0 comments on commit 9e46121

Please sign in to comment.