public void GeneratesScript_AndBuilds_DjangoApp_RunningCollectStatic(string disableCollectStatic)
        {
            // Arrange
            var appName       = "django-app";
            var volume        = CreateSampleAppVolume(appName);
            var appDir        = volume.ContainerDir;
            var appOutputDir  = "/tmp/app-output";
            var scriptBuilder = new ShellScriptBuilder();

            if (string.IsNullOrEmpty(disableCollectStatic))
            {
                scriptBuilder.AddCommand(
                    $"export {EnvironmentSettingsKeys.DisableCollectStatic}={disableCollectStatic}");
            }
            var script = scriptBuilder
                         .AddBuildCommand(
                $"{appDir} -o {appOutputDir} --platform {PythonConstants.PlatformName}")
                         // These css files should be available since 'collectstatic' is run in the script
                         .AddFileExistsCheck($"{appOutputDir}/staticfiles/css/boards.css")
                         .AddFileExistsCheck($"{appOutputDir}/staticfiles/css/uservoice.css")
                         .ToString();

            // Act
            var result = _dockerCli.Run(new DockerRunArguments
            {
                ImageId = Settings.BuildImageName,
                EnvironmentVariables = new List <EnvironmentVariable> {
                    CreateAppNameEnvVar(appName)
                },
                Volumes = new List <DockerVolume> {
                    volume
                },
                CommandToExecuteOnRun = "/bin/bash",
                CommandArguments      = new[] { "-c", script }
            });

            // Assert
            RunAsserts(
                () =>
            {
                Assert.True(result.IsSuccess);
            },
                result.GetDebugInfo());
        }
Esempio n. 2
0
        public void GeneratesScript_AndBuilds_DjangoApp_RunningCollectStatic(string disableCollectStatic)
        {
            // Arrange
            var volume        = CreateSampleAppVolume("django-app");
            var appDir        = volume.ContainerDir;
            var appOutputDir  = "/tmp/app-output";
            var scriptBuilder = new ShellScriptBuilder();

            if (string.IsNullOrEmpty(disableCollectStatic))
            {
                scriptBuilder.AddCommand(
                    $"export {EnvironmentSettingsKeys.DisableCollectStatic}={disableCollectStatic}");
            }
            var script = scriptBuilder
                         .AddBuildCommand($"{appDir} -o {appOutputDir} -l python --language-version {PythonVersions.Python37Version}")
                         .AddDirectoryExistsCheck($"{appOutputDir}/{PackagesDirectory}/django")
                         // These css files should be available since 'collectstatic' is run in the script
                         .AddFileExistsCheck($"{appOutputDir}/staticfiles/css/boards.css")
                         .AddFileExistsCheck($"{appOutputDir}/staticfiles/css/uservoice.css")
                         .ToString();

            // Act
            var result = _dockerCli.Run(
                Settings.BuildImageName,
                CreateAppNameEnvVar("django-app"),
                volume,
                commandToExecuteOnRun: "/bin/bash",
                commandArguments:
                new[]
            {
                "-c",
                script
            });

            // Assert
            RunAsserts(
                () =>
            {
                Assert.True(result.IsSuccess);
            },
                result.GetDebugInfo());
        }