• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

testit-tms / adapters-dotnet / 24459696142

15 Apr 2026 02:17PM UTC coverage: 38.512% (-0.1%) from 38.628%
24459696142

push

coveralls.net

web-flow
Merge pull request #133 from testit-tms/feat/update-sync-storage

feat: update sync-storage

3495 of 9075 relevant lines covered (38.51%)

5.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/Tms.Adapter.Core/SyncStorage/SyncStorageClient.cs
1
using System.Net.Http;
2
using Microsoft.Extensions.Logging;
3
using SyncStorage.ApiClient.Api;
4
using SyncStorage.ApiClient.Client;
5
using SyncStorage.ApiClient.Model;
6

7
namespace Tms.Adapter.Core.SyncStorage;
8

9
/// <summary>
10
/// Sync Storage HTTP API via the OpenAPI-generated client.
11
/// </summary>
12
public sealed class SyncStorageClient : IDisposable
13
{
14
    private readonly HttpClient _httpClient;
15
    private readonly HttpClientHandler _handler;
16
    private readonly HealthApi _healthApi;
17
    private readonly WorkersApi _workersApi;
18
    private readonly TestResultsApi _testResultsApi;
19
    private readonly ILogger _logger;
20

21
    public SyncStorageClient(string baseUrl, ILogger logger)
13✔
22
    {
13✔
23
        _logger = logger;
13✔
24
        var trimmed = baseUrl.TrimEnd('/');
13✔
25
        _handler = new HttpClientHandler
13✔
26
        {
13✔
27
            ServerCertificateCustomValidationCallback = (_, _, _, _) => true
×
28
        };
13✔
29
        _httpClient = new HttpClient(_handler)
13✔
30
        {
13✔
31
            Timeout = TimeSpan.FromSeconds(10)
13✔
32
        };
13✔
33

34
        var configuration = new Configuration { BasePath = trimmed };
13✔
35
        _healthApi = new HealthApi(_httpClient, configuration, _handler);
13✔
36
        _workersApi = new WorkersApi(_httpClient, configuration, _handler);
13✔
37
        _testResultsApi = new TestResultsApi(_httpClient, configuration, _handler);
13✔
38
    }
13✔
39

40
    public async Task<bool> HealthCheckAsync()
41
    {
15✔
42
        try
43
        {
15✔
44
            await _healthApi.HealthGetAsync().ConfigureAwait(false);
15✔
45
            return true;
13✔
46
        }
47
        catch
2✔
48
        {
2✔
49
            return false;
2✔
50
        }
51
    }
15✔
52

53
    public async Task<RegisterResponse> RegisterWorkerAsync(string pid, string testRunId)
54
    {
13✔
55
        _logger.LogDebug("Registering worker {Pid} for test run {TestRunId}", pid, testRunId);
13✔
56

57
        var request = new RegisterRequest(pid, testRunId);
13✔
58
        return await _workersApi.RegisterPostAsync(request).ConfigureAwait(false);
13✔
59
    }
13✔
60

61
    public async Task<bool> SendInProgressTestResultAsync(string testRunId, TestResultCutApiModel model)
62
    {
1✔
63
        _logger.LogDebug("Sending in-progress test result to Sync Storage: {ExternalId}", model.AutoTestExternalId);
1✔
64

65
        try
66
        {
1✔
67
            await _testResultsApi.InProgressTestResultPostAsync(testRunId, model).ConfigureAwait(false);
1✔
68
            return true;
1✔
69
        }
70
        catch (Exception ex)
×
71
        {
×
72
            _logger.LogDebug(ex, "Sync Storage in_progress request failed");
×
73
            return false;
×
74
        }
75
    }
1✔
76

77
    public async Task SetWorkerStatusAsync(string pid, string status, string testRunId)
78
    {
×
79
        var request = new SetWorkerStatusRequest(pid, status, testRunId);
×
80
        _logger.LogDebug("Setting worker {Pid} status to {Status}", pid, status);
×
81
        await _workersApi.SetWorkerStatusPostAsync(request).ConfigureAwait(false);
×
82
    }
×
83

84
    public void Dispose()
85
    {
×
86
        _httpClient.Dispose();
×
87
        _handler.Dispose();
×
88
    }
×
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc