public void UseNode10ForNodeHandlerEnvVarSet() { try { Environment.SetEnvironmentVariable("AGENT_USE_NODE10", "true"); using (TestHostContext thc = CreateTestHostContext()) { thc.SetSingleton(new WorkerCommandManager() as IWorkerCommandManager); thc.SetSingleton(new ExtensionManager() as IExtensionManager); NodeHandler nodeHandler = new NodeHandler(); nodeHandler.Initialize(thc); nodeHandler.ExecutionContext = CreateTestExecutionContext(thc); nodeHandler.Data = new Node10HandlerData(); string actualLocation = nodeHandler.GetNodeLocation(); string expectedLocation = Path.Combine(thc.GetDirectory(WellKnownDirectory.Externals), "node10", "bin", $"node{IOUtil.ExeExtension}"); Assert.Equal(expectedLocation, actualLocation); } } finally { Environment.SetEnvironmentVariable("AGENT_USE_NODE10", null); } }
public void UseNode10ForNode10HandlerHostContextVarUnset() { using (TestHostContext thc = CreateTestHostContext()) { thc.SetSingleton(new WorkerCommandManager() as IWorkerCommandManager); thc.SetSingleton(new ExtensionManager() as IExtensionManager); var variables = new Dictionary <string, VariableValue>(); // Explicitly set 'AGENT_USE_NODE10' feature flag to false variables.Add("AGENT_USE_NODE10", new VariableValue("false")); NodeHandler nodeHandler = new NodeHandler(); nodeHandler.Initialize(thc); nodeHandler.ExecutionContext = CreateTestExecutionContext(thc, variables); nodeHandler.Data = new Node10HandlerData(); // Node10 handler is unaffected by the 'AGENT_USE_NODE10' feature flag, so folder name should be 'node10' string actualLocation = nodeHandler.GetNodeLocation(); string expectedLocation = Path.Combine(thc.GetDirectory(WellKnownDirectory.Externals), "node10", "bin", $"node{IOUtil.ExeExtension}"); Assert.Equal(expectedLocation, actualLocation); } }
public void UseNode10ForNodeHandlerHostContextVarSet() { using (TestHostContext thc = CreateTestHostContext()) { thc.SetSingleton(new WorkerCommandManager() as IWorkerCommandManager); thc.SetSingleton(new ExtensionManager() as IExtensionManager); var variables = new Dictionary <string, VariableValue>(); variables.Add("AGENT_USE_NODE10", new VariableValue("true")); NodeHandler nodeHandler = new NodeHandler(); nodeHandler.Initialize(thc); nodeHandler.ExecutionContext = CreateTestExecutionContext(thc, variables); nodeHandler.Data = new NodeHandlerData(); string actualLocation = nodeHandler.GetNodeLocation(); string expectedLocation = Path.Combine(thc.GetDirectory(WellKnownDirectory.Externals), "node10", "bin", $"node{IOUtil.ExeExtension}"); Assert.Equal(expectedLocation, actualLocation); } }
public void UseNodeForNodeHandlerEnvVarNotSet() { using (TestHostContext thc = CreateTestHostContext()) { thc.SetSingleton(new WorkerCommandManager() as IWorkerCommandManager); thc.SetSingleton(new ExtensionManager() as IExtensionManager); NodeHandler nodeHandler = new NodeHandler(); nodeHandler.Initialize(thc); nodeHandler.ExecutionContext = CreateTestExecutionContext(thc); nodeHandler.Data = new NodeHandlerData(); string actualLocation = nodeHandler.GetNodeLocation(); string expectedLocation = Path.Combine(thc.GetDirectory(WellKnownDirectory.Externals), "node", "bin", $"node{IOUtil.ExeExtension}"); Assert.Equal(expectedLocation, actualLocation); } }