Beispiel #1
0
        public async Task WordPressDockerComposeServiceShallShowInstallScreen()
        {
            var file = Path.Combine(Directory.GetCurrentDirectory(),
                                    (TemplateString)"Resources/ComposeTests/WordPress/docker-compose.yml");

            using (var svc = new DockerComposeCompositeService(DockerHost, new DockerComposeConfig
            {
                ComposeFilePath = new List <string> {
                    file
                },
                ForceRecreate = true,
                RemoveOrphans = true,
                StopOnDispose = true
            }))
            {
                svc.Start();

                svc.Containers.First(x => x.Name == "wordpress").WaitForHttp("http://localhost:8000/wp-admin/install.php");

                // We now have a running WordPress with a MySql database
                var installPage = await $"http://localhost:8000/wp-admin/install.php".Wget();

                Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);
            }
        }
Beispiel #2
0
 private DockerSetup(IHostService hostService, IList <string> composeFiles)
 {
     _dockerSetup = new DockerComposeCompositeService(hostService, new DockerComposeConfig
     {
         ComposeFilePath = composeFiles,
         ForceBuild      = true,
         ForceRecreate   = true,
         RemoveOrphans   = true,
         StopOnDispose   = true
     });
 }
Beispiel #3
0
        public void StartErrorMessageShallContainDockerComposeFilePaths(string[] nonExistentComposeFiles)
        {
            var svc = new DockerComposeCompositeService(DockerHost, new DockerComposeConfig
            {
                ComposeFilePath = new List <string>(nonExistentComposeFiles),
                ForceRecreate   = true,
                RemoveOrphans   = true,
                StopOnDispose   = true
            });

            var ex = Assert.ThrowsException <FluentDockerException>(() => svc.Start());

            foreach (var nonExistentComposeFile in nonExistentComposeFiles)
            {
                Assert.IsTrue(ex.Message.Contains(nonExistentComposeFile));
            }
        }
Beispiel #4
0
        public override ICompositeService Build()
        {
            if (_config.ComposeFilePath.Count == 0)
            {
                throw new FluentDockerException("Cannot create service without a docker-compose file");
            }

            var host = FindHostService();

            if (!host.HasValue)
            {
                throw new FluentDockerException(
                          $"Cannot build service using compose-file {_config.ComposeFilePath} since no host service is defined");
            }

            var container = new DockerComposeCompositeService(host.Value, _config);

            AddHooks(container);

            return(container);
        }