-
Notifications
You must be signed in to change notification settings - Fork 7
use postgres and EF migrations #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0b7c14a
7f56cd5
42a870f
816b700
1cfb02f
d406e53
3f14499
64a66cf
46cf052
6fcbab2
31a6d35
fcddee2
9880d1a
0fcc230
517c757
f55f5b7
8449f5f
7b71634
ddbde08
56a8487
320a0ae
55235e8
94125c0
038e404
6fc6fcf
128ac4c
528b3cf
75c14be
33e8fb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,14 +39,14 @@ | |
| _mockInnerHandler.Send(Arg.Any<HttpRequestMessage>(), Arg.Any<CancellationToken>()) | ||
| .Returns(Task.FromResult(new HttpResponseMessage { StatusCode = HttpStatusCode.OK })); | ||
|
|
||
| var handler = new GithubRetryHandler(_mockInnerHandler, _config, _logger); | ||
| var handler = new GithubRetryHandler(_config, _logger) { InnerHandler = _mockInnerHandler }; | ||
| var httpClient = new HttpClient(handler); | ||
|
|
||
| // Act | ||
| var result = httpClient.SendAsync(_httpRequestMessage, default).Result; | ||
|
|
||
| // Assert | ||
| Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); | ||
|
Check warning on line 49 in SS14.Labeller.Tests/GitHubApi/GithubRetryHandlerTests.cs
|
||
| } | ||
|
|
||
| [Test] | ||
|
|
@@ -55,18 +55,18 @@ | |
| // Arrange | ||
| _mockInnerHandler.Send(Arg.Any<HttpRequestMessage>(), Arg.Any<CancellationToken>()) | ||
| .Returns( | ||
| _=> throw new HttpRequestException(HttpRequestError.ConnectionError), | ||
| _=> Task.FromResult(new HttpResponseMessage { StatusCode = HttpStatusCode.OK }) | ||
| _ => throw new HttpRequestException(HttpRequestError.ConnectionError), | ||
| _ => Task.FromResult(new HttpResponseMessage { StatusCode = HttpStatusCode.OK }) | ||
| ); | ||
|
|
||
| var handler = new GithubRetryHandler(_mockInnerHandler, _config, _logger); | ||
| var handler = new GithubRetryHandler(_config, _logger) { InnerHandler = _mockInnerHandler }; | ||
| var httpClient = new HttpClient(handler); | ||
|
|
||
| // Act | ||
| var result = httpClient.SendAsync(_httpRequestMessage, default).Result; | ||
|
|
||
| // Assert | ||
| Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); | ||
|
Check warning on line 69 in SS14.Labeller.Tests/GitHubApi/GithubRetryHandlerTests.cs
|
||
| } | ||
|
|
||
| [Test] | ||
|
|
@@ -87,7 +87,7 @@ | |
| _mockInnerHandler.Send(Arg.Any<HttpRequestMessage>(), Arg.Any<CancellationToken>()) | ||
| .Returns(response1, response2); | ||
|
|
||
| var handler = new GithubRetryHandler(_mockInnerHandler, _config, _logger); | ||
| var handler = new GithubRetryHandler(_config, _logger) { InnerHandler = _mockInnerHandler }; | ||
| var httpClient = new HttpClient(handler); | ||
|
|
||
| // Act | ||
|
|
@@ -108,7 +108,7 @@ | |
|
|
||
| _gitHubConfig.MaxRetryAttempt = 2; | ||
|
|
||
| var handler = new GithubRetryHandler(_mockInnerHandler, _config, _logger); | ||
| var handler = new GithubRetryHandler(_config, _logger) { InnerHandler = _mockInnerHandler }; | ||
| var httpClient = new HttpClient(handler); | ||
|
|
||
| // Act & Assert | ||
|
|
@@ -128,7 +128,7 @@ | |
| return Send(request, cancellationToken); | ||
| } | ||
|
|
||
| public virtual Task<HttpResponseMessage> Send(HttpRequestMessage request, CancellationToken cancellationToken) | ||
|
Check warning on line 131 in SS14.Labeller.Tests/GitHubApi/GithubRetryHandlerTests.cs
|
||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| using System.Threading.Tasks; | ||
| using Dapper; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Npgsql; | ||
| using NUnit.Framework; | ||
| using SS14.Labeller.Repository; | ||
|
|
||
| namespace SS14.Labeller.Tests.IntegrationTests.Repository; | ||
|
|
||
| public class DiscourseTopicsRepositoryTests | ||
| { | ||
| private IDiscourseTopicsRepository _repository; | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| _repository = new DiscourseTopicsRepository(TestSetup.Configuration); | ||
|
|
||
| CleanUpDb(); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task HasTopic_NoSuchParamsCombination_IsFalse() | ||
| { | ||
| // Arrange | ||
|
|
||
| // Act | ||
| var actual = await _repository.HasTopic("some-random-owner", "some-random-name", 54353, default); | ||
|
|
||
| // Assert | ||
| Assert.That(actual, Is.False); | ||
| } | ||
|
|
||
|
|
||
| [Test] | ||
| public async Task Add_DoesNotExist_IsAdded() | ||
| { | ||
| // Arrange | ||
| const string owner = "some-random-owner"; | ||
| const string repoName = "some-random-name"; | ||
| const int issueNumber = 54353; | ||
| var before = await _repository.HasTopic(owner, repoName, issueNumber, default); | ||
|
|
||
| // Act | ||
| await _repository.Add(owner, repoName, issueNumber, 1231, default); | ||
|
|
||
| // Assert | ||
| var after = await _repository.HasTopic(owner, repoName, issueNumber, default); | ||
|
|
||
| Assert.That(before, Is.False); | ||
| Assert.That(after, Is.True); | ||
| } | ||
|
|
||
| [TearDown] | ||
| public void TearDown() | ||
| { | ||
| CleanUpDb(); | ||
| } | ||
|
|
||
| private static void CleanUpDb() | ||
| { | ||
| var connectionString = TestSetup.Configuration.GetConnectionString("Default"); | ||
| using var con = new NpgsqlConnection(connectionString); | ||
| con.Open(); | ||
| con.Execute("TRUNCATE TABLE discourse.discussions"); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using System.IO; | ||
| using Microsoft.Extensions.Configuration; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace SS14.Labeller.Tests; | ||
|
|
||
| [SetUpFixture] | ||
| public class TestSetup | ||
| { | ||
| public static IConfiguration Configuration { get; private set; } | ||
|
|
||
| [OneTimeSetUp] | ||
| public void RunBeforeAnyTests() | ||
| { | ||
| Configuration = new ConfigurationBuilder() | ||
| .SetBasePath(Directory.GetCurrentDirectory()) | ||
| .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) | ||
| .AddEnvironmentVariables() | ||
| .Build(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,15 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.13.35818.85 d17.13 | ||
| VisualStudioVersion = 17.13.35818.85 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pepeHands when will M$ release xml-based sln files, ffs |
||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SS14.Labeller", "SS14.Labeller\SS14.Labeller.csproj", "{23A01977-7FE4-491F-BBE8-E8C412D8D753}" | ||
| EndProject | ||
| Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}" | ||
| ProjectSection(SolutionItems) = preProject | ||
| docker-compose-debug.yml = docker-compose-debug.yml | ||
| docker-compose.yml = docker-compose.yml | ||
| Dockerfile = Dockerfile | ||
| README.md = README.md | ||
| EndProjectSection | ||
| EndProject | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would make the container not run since the dotnet runtime is not in the container
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--self-contained trueis still there - why would there be problem with that?!Tested it with this Dockerfile and got no 'missing dotnet' problem :/ am i doing something wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right! Yeah. Though for download size it would probably be best that the Docker image your standard dotnet runtime image since then users won't have to download the runtime twice if they already had a docker image with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you would better like to have 9.0.9-alpine3.22 here instead of what it currently uses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed