Beispiel #1
0
        public void TestBuildIsoDryrun()
        {
            var input = new LineInputter(Resources.BuildIsoConfig);

            using var requests = new MockVultrRequests(
                      new HttpHandler(
                          "account/info", Resources.VultrAccountInfo),
                      new HttpHandler(
                          "startupscript/list",
                          new[]
            {
                StartupScriptListWithBuildIso, StartupScriptListWithBuildIso
            }),
                      new HttpHandler("os/list", Resources.VultrOSList),
                      new HttpHandler(
                          "regions/list?availability=yes",
                          Resources.VultrRegionsList),
                      new HttpHandler(
                          "plans/list?type=all", Resources.VultrPlansList),
                      new HttpHandler(
                          "firewall/group_list", Resources.VultrFirewallGroupsPublic),
                      new HttpHandler("sshkey/list", "{}"),
                      new HttpHandler("server/list", "{}"));

            AProgram.Main(null, input.ReadLine,
                          "provision", "--dryrun",
                          "--apikey", ApiKey,
                          "--apiurl", requests.Url).Should().Be(0);
            requests.AssertAllCalledOnce();
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
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();
        }
Beispiel #5
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();
        }
Beispiel #6
0
        public void TestBuildIsoDryrunNoBuildScript()
        {
            var input = new LineInputter(Resources.BuildIsoConfig);

            using var requests = new MockVultrRequests(
                      new HttpHandler(
                          "account/info", Resources.VultrAccountInfo),
                      new HttpHandler(
                          "startupscript/list",
                          new[]
            {
                "{}", "{}"
            }));

            AProgram.Main(null, input.ReadLine,
                          "provision", "--dryrun",
                          "--apikey", ApiKey,
                          "--apiurl", requests.Url).Should().Be(3);
            requests.AssertAllCalledOnce();
        }