Пример #1
0
        public void TestLoadCustomPlatform()
        {
            var agrix = new Agrix("platform: test",
                                  new AgrixSettings("abc", "http://example.org/", TestAssembly));

            Assert.Equal(typeof(TestPlatform), agrix.LoadPlatform().GetType());
        }
Пример #2
0
        public void TestLoadPlatform()
        {
            var agrix = new Agrix(
                "platform: vultr", BasicSettings);

            Assert.Equal(
                typeof(VultrPlatform), agrix.LoadPlatform().GetType());
        }
Пример #3
0
        public void TestValidate()
        {
            using var requests = new MockVultrRequests(
                      new HttpHandler("/account/info"));
            var agrix = new Agrix(
                Resources.SimpleConfig, new AgrixSettings("abc", requests.Url));

            agrix.Validate();
        }
Пример #4
0
        public void TestValidateServer(string configName)
        {
            using var requests = new MockVultrRequests(
                      new HttpHandler("/account/info"));
            var config = Resources.ResourceManager.GetString(configName);
            var agrix  = new Agrix(config, new AgrixSettings("abc", requests.Url));

            agrix.Validate();
        }
Пример #5
0
        public void TestDestroy(bool dryrun)
        {
            using var requests = new MockVultrRequests(
                      new HttpHandler(
                          "destroy",
                          $"label=myserver&dryrun={dryrun}",
                          ""));
            var agrix = new Agrix(Resources.TestPlatformConfig,
                                  new AgrixSettings("abc", requests.Url, TestAssembly));

            agrix.Destroy(dryrun);
            requests.AssertAllCalledOnce();
        }
Пример #6
0
        public void TestProcess(bool dryrun)
        {
            var expected = "plan.cpu=2&plan.memory=4096&plan.type=SSD&" +
                           "os.name=Fedora%2032%20x64&os.app=Fedora%2032%20x64&" +
                           $"os.iso=&dryrun={dryrun}";

            using var requests = new MockVultrRequests(
                      new HttpHandler("provision", expected, ""));
            var agrix = new Agrix(Resources.TestPlatformConfig,
                                  new AgrixSettings("abc", requests.Url, TestAssembly));

            agrix.Process(dryrun);
            requests.AssertAllCalledOnce();
        }
Пример #7
0
        public void TestValidateInvalidServer()
        {
            var agrix = new Agrix(Resources.InvalidServerConfig, BasicSettings);

            Assert.Throws <AgrixValidationException>(() => agrix.Validate());
        }
Пример #8
0
        public void TestValidateUnsupportedPlatform()
        {
            var agrix = new Agrix("platform:", BasicSettings);

            Assert.Throws <AgrixValidationException>(() => agrix.Validate());
        }
Пример #9
0
        public void TestValidatePlatformIsRequired()
        {
            var agrix = new Agrix("servers:", BasicSettings);

            Assert.Throws <AgrixValidationException>(() => agrix.Validate());
        }