mirror of https://github.com/dotnet/tye.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.7 KiB
45 lines
1.7 KiB
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Tye;
|
|
using Test.Infrastructure;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace E2ETest
|
|
{
|
|
public class ApplicationTests
|
|
{
|
|
private readonly TestOutputLogEventSink _sink;
|
|
|
|
public ApplicationTests(ITestOutputHelper output)
|
|
{
|
|
_sink = new TestOutputLogEventSink(output);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task EnvironmentVariablesOnlySetForDirectDependencies()
|
|
{
|
|
using var projectDirectory = TestHelpers.CopyTestProjectDirectory(Path.Combine("multirepo"));
|
|
var yamlFile = Path.Combine(projectDirectory.DirectoryPath, "results", "tye.yaml");
|
|
|
|
// Debug targets can be null if not specified, so make sure calling host.Start does not throw.
|
|
var outputContext = new OutputContext(_sink, Verbosity.Debug);
|
|
var projectFile = new FileInfo(yamlFile);
|
|
var application = await ApplicationFactory.CreateAsync(outputContext, projectFile);
|
|
|
|
var app = application.ToHostingApplication();
|
|
var dictionary = new Dictionary<string, string>();
|
|
app.PopulateEnvironment(app.Services["results"], (s1, s2) => dictionary[s1] = s2);
|
|
|
|
// Just the worker and results are defined.
|
|
Assert.Equal(16, dictionary.Count);
|
|
|
|
Assert.Equal("http", dictionary["SERVICE__WORKER__PROTOCOL"]);
|
|
Assert.Equal("http", dictionary["SERVICE__RESULTS__PROTOCOL"]);
|
|
// No POSTGRES or REDIS
|
|
Assert.False(dictionary.ContainsKey("SERVICE__POSTGRES__PROTOCOL"));
|
|
Assert.False(dictionary.ContainsKey("SERVICE__REDIS__PROTOCOL"));
|
|
}
|
|
}
|
|
}
|
|
|