Skip to content

Commit

Permalink
Improving integration test, fixing non-exhaustive switch and adding t…
Browse files Browse the repository at this point in the history
…est for that
  • Loading branch information
arthrp committed Nov 6, 2024
1 parent 7f211cc commit 87fd7ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RqliteDotnet.IntegrationTest/RqliteClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Text.RegularExpressions;
using DotNet.Testcontainers.Builders;
using NUnit.Framework;

Expand All @@ -24,5 +25,6 @@ public async Task RqliteClientPing_Works()
var version = await client.Ping();

Assert.That(version, Is.Not.Empty);
Assert.That(Regex.IsMatch(version, @"v\d+.\d+.+")); //v8.10.1
}
}
9 changes: 9 additions & 0 deletions RqliteDotnet.Test/UrlBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using NUnit.Framework;

namespace RqliteDotnet.Test;
Expand Down Expand Up @@ -25,4 +26,12 @@ public void UrlBuilder_BuildsCorrectUrlWithReadLevel()
Assert.That(url.StartsWith(baseUrl));
Assert.That(url, Is.EqualTo("/db/query?timings&q=select%20%2A%20from%20foo&level=strong"));
}

[Test]
public void UrlBuilder_ThrowsWhenIncorrectReadLevelSupplied()
{
var query = "select * from foo";
var baseUrl = "/db/query?timings";
Assert.Throws<ArgumentException>(() => UrlBuilder.Build(baseUrl, query, (ReadLevel)0));
}
}
3 changes: 2 additions & 1 deletion RqliteDotnet/UrlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ private static string GetReadLevel(ReadLevel level)
ReadLevel.Linearizable => "&level=linearizable",
ReadLevel.Strong => "&level=strong",
ReadLevel.None => "&level=none",
ReadLevel.Auto => "&level=auto"
ReadLevel.Auto => "&level=auto",
_ => throw new ArgumentException("Unknown read level")
};
return result;
}
Expand Down

0 comments on commit 87fd7ba

Please sign in to comment.