Example #1
0
        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);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        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);
            }
        }
Example #4
0
        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);
            }
        }