Exemplo n.º 1
0
        public void TestValidateInvalid()
        {
            var input = new LineInputter("what is this nonsense");

            Assert.Equal(1, AProgram.Main(_testAssembly, input.ReadLine,
                                          "validate", "--apikey", "abc"));
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        public void TestValidate()
        {
            var input = new LineInputter(Resources.TestPlatformConfig);

            Assert.Equal(0, AProgram.Main(_testAssembly, input.ReadLine,
                                          "validate", "--apiurl", "http://example.org/"));
        }
Exemplo n.º 4
0
        public void TestProvisionDryrun()
        {
            const string expected = "plan.cpu=2&plan.memory=4096&plan.type=SSD&" +
                                    "os.name=Fedora%2032%20x64&os.app=Fedora%2032%20x64&" +
                                    "os.iso=&dryrun=True";

            using var requests = new MockVultrRequests(
                      new HttpHandler(
                          "provision", expected, ""));
            var input = new LineInputter(Resources.TestPlatformConfig);

            Assert.Equal(0, AProgram.Main(_testAssembly, input.ReadLine,
                                          "provision", "--apiurl", requests.Url, "--dryrun"));
            requests.AssertAllCalledOnce();
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
 public void TestHelp()
 {
     Assert.Equal(
         0,
         AProgram.Main(_testAssembly, ReadLine, "help"));
 }
Exemplo n.º 7
0
 public void TestBadArguments()
 {
     Assert.Equal(
         2,
         AProgram.Main(_testAssembly, ReadLine, "bad", "arguments"));
 }