Files
csharp/tests/KubernetesClient.Tests/ExternalExecutionTests.cs
Boshi Lian eca9898902 API v1.23.0 + system.text.json + remove WatchXXX API (#750)
* gen v1.23.0

* fix converter

* bump ver

* update readme runtime

* fix warning

* update dep ver

* newtonjson -> system.text.json

* generate for new json api

* readme lf

* dotnet fmt

* dotnet fmt tests/

* dotnet fmt

* Revert "dotnet fmt"

This reverts commit e14c59076143fe2218ed899295a00762f0ea2bd6.

* fix err introduce by dotnet fmt

* fix test

* remove deprecated /watch api

* generate code after /watch removed

* remove /watch related code

* trim Microsoft.Rest.Serialization
2021-12-13 07:31:59 -08:00

32 lines
1.2 KiB
C#

using System.Collections.Generic;
using System.Text.Json;
using k8s.KubeConfigModels;
using Xunit;
namespace k8s.Tests
{
public class ExternalExecutionTests
{
[Fact]
public void CreateRunnableExternalProcess()
{
var actual = KubernetesClientConfiguration.CreateRunnableExternalProcess(new ExternalExecution
{
ApiVersion = "testingversion",
Command = "command",
Arguments = new List<string> { "arg1", "arg2" },
EnvironmentVariables = new List<Dictionary<string, string>>
{ new Dictionary<string, string> { { "name", "testkey" }, { "value", "testvalue" } } },
});
var actualExecInfo = JsonSerializer.Deserialize<IDictionary<string, dynamic>>(actual.StartInfo.EnvironmentVariables["KUBERNETES_EXEC_INFO"]);
Assert.Equal("testingversion", actualExecInfo["apiVersion"].ToString());
Assert.Equal("ExecCredentials", actualExecInfo["kind"].ToString());
Assert.Equal("command", actual.StartInfo.FileName);
Assert.Equal("arg1 arg2", actual.StartInfo.Arguments);
Assert.Equal("testvalue", actual.StartInfo.EnvironmentVariables["testkey"]);
}
}
}