Skip to content

Commit

Permalink
Revert "Libs(CSharp): add kitchen sink test"
Browse files Browse the repository at this point in the history
This reverts commit 1f05d0e.

The test new runs fine on dotnet 8.0, but CI complains about something
in the source using language features too new.

The project currently targets dotnet 5.0, which seems to be EOL, so we
should look at updating the target first, after we can un-revert this
test.

For now, just know the test passed for me with a tweak to the Svix.Test
solution so it can run on 8.0. This gives me some confidence that the
generator bump produced some okay code.
  • Loading branch information
svix-onelson committed Oct 17, 2024
1 parent 1f05d0e commit ba22cf1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 79 deletions.
17 changes: 0 additions & 17 deletions csharp/Svix.Tests/IgnoreIfClientVarsUnset.cs

This file was deleted.

75 changes: 13 additions & 62 deletions csharp/Svix.Tests/SvixClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,74 +1,25 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging.Abstractions;
using Svix.Client;
using Svix.Model;
using Microsoft.Extensions.Logging.Abstractions;
using Svix.Models;
using Xunit;

namespace Svix.Tests;

public class SvixClientTests
namespace Svix.Tests
{
[Fact]
public void Constructor_WhenCalled_DoesNotNeedLogger()
{
var sut = new SvixClient("", new SvixOptions("http://some.url"));

Assert.NotNull(sut);
}

[Fact]
public void Constructor_WhenCalled_AcceptsLogger()
public class SvixClientTests
{
var sut = new SvixClient("", new SvixOptions("http://some.url"), new NullLogger<SvixClient>());

Assert.NotNull(sut);
}

[IgnoreIfClientVarsUnset]
public void KitchenSink_SeemsToWorkOkay()
{
var token = Environment.GetEnvironmentVariable("SVIX_TOKEN");
var url = Environment.GetEnvironmentVariable("SVIX_SERVER_URL");
var client = new SvixClient(token, new SvixOptions(url));

var app = client.Application.Create(new ApplicationIn(name: "App"));
try
[Fact]
public void Constructor_WhenCalled_DoesNotNeedLogger()
{
client.EventType.Create(new EventTypeIn(name: "event.started", description: "Something started"));
}
catch (ApiException e)
{
// We expect conflicts, but any other status is an error
Assert.Equal(409, e.ErrorCode);
}
var sut = new SvixClient("", new SvixOptions("http://some.url"));

try
{
client.EventType.Create(new EventTypeIn(name: "event.ended", description: "Something ended"));
}
catch (ApiException e)
{
// We expect conflicts, but any other status is an error
Assert.Equal(409, e.ErrorCode);
Assert.NotNull(sut);
}

var ep = client.Endpoint.Create(app.Id,
new EndpointIn(url: "https://example.svix.com/", channels: new List<string> { "ch0", "ch1" }));

ep.Channels.Sort();
Assert.Equal(new List<string> { "ch0", "ch1" }, ep.Channels);
Assert.Null(ep.FilterTypes);

var epPatched = client.Endpoint.Patch(app.Id, ep.Id,
new EndpointPatch(filterTypes: new List<string> { "event.started", "event.ended" }));
epPatched.Channels.Sort();
epPatched.FilterTypes.Sort();
Assert.Equal(new List<string> { "ch0", "ch1" }, epPatched.Channels);
Assert.Equal(new List<string> { "event.ended", "event.started" }, epPatched.FilterTypes);
[Fact]
public void Constructor_WhenCalled_AcceptsLogger()
{
var sut = new SvixClient("", new SvixOptions("http://some.url"), new NullLogger<SvixClient>());

// Should not throw an exception if the serialization code handles empty bodies properly
client.Endpoint.Delete(app.Id, ep.Id);
Assert.NotNull(sut);
}
}
}

0 comments on commit ba22cf1

Please sign in to comment.