2020-04-08 22:28:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Dapper;
|
|
|
|
|
using Wabbajack.BuildServer.Model.Models;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
using Wabbajack.Lib;
|
|
|
|
|
using Xunit;
|
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.BuildServer.Test
|
|
|
|
|
{
|
|
|
|
|
public class MetricsTests : ABuildServerSystemTest
|
|
|
|
|
{
|
|
|
|
|
public MetricsTests(ITestOutputHelper output, SingletonAdaptor<BuildServerFixture> fixture) : base(output, fixture)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task CanSendMetrics()
|
|
|
|
|
{
|
|
|
|
|
var action = "action_" + Guid.NewGuid().ToString();
|
|
|
|
|
var subject = "subject_" + Guid.NewGuid().ToString();
|
|
|
|
|
await Metrics.Send(action, subject);
|
|
|
|
|
|
|
|
|
|
var sql = Fixture.GetService<SqlService>();
|
|
|
|
|
var conn = await sql.Open();
|
|
|
|
|
var result = await conn.QueryFirstOrDefaultAsync<string>("SELECT Subject FROM dbo.Metrics WHERE Action = @Action",
|
|
|
|
|
new {Action = action});
|
|
|
|
|
|
|
|
|
|
Assert.Equal(subject, result);
|
|
|
|
|
}
|
2020-04-26 05:13:42 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task CanLoadMetricsFromSQL()
|
|
|
|
|
{
|
|
|
|
|
var sql = Fixture.GetService<SqlService>();
|
|
|
|
|
var results = await sql.MetricsReport("finish_install");
|
|
|
|
|
}
|
2020-04-08 22:28:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|