public async Task TestGetKubectlContextForClusterAsync_RunsCommandAgainstExpectedZone() { const string expectedZone = "expected-zone"; await KubectlContext.GetKubectlContextForClusterAsync(DefaultCluster, expectedZone); VerifyCommandArgsContain($"--zone={expectedZone}"); }
public async Task TestDispose_NonReentrant() { _objectUnderTest = await KubectlContext.GetKubectlContextForClusterAsync(DefaultCluster, DefaultZone); _objectUnderTest.Dispose(); _objectUnderTest.Dispose(); PackageMock.Verify(p => p.GetMefService <IFileSystem>().File.Delete(It.IsAny <string>()), Times.Once); }
public async Task TestGetKubectlContextForClusterAsync_ThrowsOnCommandFailure() { SetupRunCommandResult(false); GCloudException e = await Assert.ThrowsExceptionAsync <GCloudException>( () => KubectlContext.GetKubectlContextForClusterAsync(ExpectedCluster, DefaultZone)); StringAssert.Contains(e.Message, ExpectedCluster); }
public async Task TestGetKubectlContextForClusterAsync_RunsCommandWithKubeConfigEnvVar() { IDictionary <string, string> environment = new Dictionary <string, string>(); SetupRunCommandGetEnvironment(commandEnvironment => environment = commandEnvironment); await KubectlContext.GetKubectlContextForClusterAsync(DefaultCluster, DefaultZone); Assert.IsTrue(environment.ContainsKey(KubectlContext.KubeConfigVariable)); }
public async Task TestGetKubectlContextForClusterAsync_RunsCommandWithExpectedUseDefaultCredentialsEnvVar() { IDictionary <string, string> environment = new Dictionary <string, string>(); SetupRunCommandGetEnvironment(commandEnvironment => environment = commandEnvironment); await KubectlContext.GetKubectlContextForClusterAsync(DefaultCluster, DefaultZone); Assert.AreEqual( KubectlContext.TrueValue, environment[KubectlContext.UseApplicationDefaultCredentialsVariable]); }
public async Task TestGetKubectlContextForClusterAsync_RunsCommandWithExpectedGoogleCredentialsEnvVar() { const string expectedCredentialsPath = "expected-credentials-path"; CredentialStoreMock.Setup(cs => cs.CurrentAccountPath).Returns(expectedCredentialsPath); IDictionary <string, string> environment = new Dictionary <string, string>(); SetupRunCommandGetEnvironment(commandEnvironment => environment = commandEnvironment); await KubectlContext.GetKubectlContextForClusterAsync(DefaultCluster, DefaultZone); Assert.AreEqual(expectedCredentialsPath, environment[KubectlContext.GoogleApplicationCredentialsVariable]); }
public async Task TestDispose_DeletesConfigPath() { IDictionary <string, string> environment = new Dictionary <string, string>(); SetupRunCommandGetEnvironment(commandEnvironment => environment = commandEnvironment); _objectUnderTest = await KubectlContext.GetKubectlContextForClusterAsync(DefaultCluster, DefaultZone); _objectUnderTest.Dispose(); string expectedDeletePath = environment[KubectlContext.KubeConfigVariable]; PackageMock.Verify(p => p.GetMefService <IFileSystem>().File.Delete(expectedDeletePath)); }
public async Task BeforeEachAsync() { _processServiceMock = new Mock <IProcessService>(); PackageMock.Setup(p => p.ProcessService).Returns(_processServiceMock.Object); _kubeConfigPath = null; SetupRunCommandGetEnvironment( defaultInitKubectlEnvironment => _kubeConfigPath = _kubeConfigPath ?? defaultInitKubectlEnvironment[KubectlContext.KubeConfigVariable]); _objectUnderTest = await KubectlContext.GetKubectlContextForClusterAsync(DefaultCluster, DefaultZone); _mockedOutputAction = Mock.Of <Action <string> >(); }
public async Task TestGetKubectlContextForClusterAsync_RunsCommandAgainstExpectedCluster() { await KubectlContext.GetKubectlContextForClusterAsync(ExpectedCluster, DefaultZone); VerifyCommandArgsContain(ExpectedCluster); }
public async Task TestGetKubectlContextForClusterAsync_RunsGcloudContainerClustersGetCredentials() { await KubectlContext.GetKubectlContextForClusterAsync(DefaultCluster, DefaultZone); VerifyCommandArgsContain("gcloud container clusters get-credentials"); }