-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathTerraWsmApiClientIntegrationTests.cs
75 lines (62 loc) · 2.5 KB
/
TerraWsmApiClientIntegrationTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TesApi.Web.Management;
using TesApi.Web.Management.Clients;
using TesApi.Web.Management.Configuration;
namespace TesApi.Tests.Integration
{
[TestClass, TestCategory("TerraIntegration")]
[Ignore]
public class TerraWsmApiClientIntegrationTests
{
private TerraWsmApiClient wsmApiClient = null!;
private TestTerraEnvInfo envInfo = null!;
[TestInitialize]
public void Setup()
{
envInfo = new TestTerraEnvInfo();
var terraOptions = Options.Create(new TerraOptions()
{
WsmApiHost = envInfo.WsmApiHost
});
var retryOptions = Options.Create(new RetryPolicyOptions());
var memoryCache = new MemoryCache(new MemoryCacheOptions());
wsmApiClient = new TerraWsmApiClient(new TestEnvTokenCredential(), terraOptions,
new CacheAndRetryHandler(memoryCache, retryOptions), TestLoggerFactory.Create<TerraWsmApiClient>());
}
[TestMethod]
public async Task GetContainerResourcesAsync_CallsUsingTheWSIdFromContainerName_ReturnsContainerInformation()
{
var workspaceId = Guid.Parse(envInfo.WorkspaceContainerName.Replace("sc-", ""));
var results = await wsmApiClient.GetContainerResourcesAsync(workspaceId, 0, 100, CancellationToken.None);
Assert.IsNotNull(results);
Assert.IsTrue(results.Resources.Any(i => i.ResourceAttributes.AzureStorageContainer.StorageContainerName.Equals(envInfo.WorkspaceContainerName, StringComparison.OrdinalIgnoreCase)));
}
}
public static class TestLoggerFactory
{
private static readonly ILoggerFactory SLogFactory = LoggerFactory.Create(builder =>
{
builder
.AddSystemdConsole(options =>
{
options.IncludeScopes = true;
options.TimestampFormat = "yyyy-MM-dd HH:mm:ss.fff ";
options.UseUtcTimestamp = true;
});
builder.SetMinimumLevel(LogLevel.Trace);
});
public static ILogger<T> Create<T>()
{
return SLogFactory.CreateLogger<T>();
}
}
}