Ejemplo n.º 1
0
 def test_clean_pull_removes_dotnet_dir(self):
     dotnet_dir = os.path.join('parts', 'test-part', 'dotnet', 'sdk')
     os.makedirs(dotnet_dir)
     plugin = dotnet.DotNetPlugin(
         'test-part', self.options, self.project)
     plugin.clean_pull()
     self.assertThat(dotnet_dir, Not(DirExists()))
Ejemplo n.º 2
0
    def test_build_commands(self):
        self.options.build_attributes = self.build_attributes
        plugin = dotnet.DotNetPlugin("test-part", self.options, self.project)
        _setup_dirs(plugin)
        plugin.build()

        part_dir = os.path.join(self.path, "parts", "test-part")
        dotnet_command = os.path.join(part_dir, "dotnet", "sdk", "dotnet")
        self.assertThat(
            self.mock_check_call.mock_calls,
            Equals([
                mock.call(
                    [dotnet_command, "build", "-c", self.configuration],
                    cwd=mock.ANY,
                ),
                mock.call(
                    [
                        dotnet_command,
                        "publish",
                        "-c",
                        self.configuration,
                        "-o",
                        plugin.installdir,
                        "--self-contained",
                        "-r",
                        "linux-x64",
                    ],
                    cwd=mock.ANY,
                ),
            ]),
        )
Ejemplo n.º 3
0
    def test_build_changes_executable_permissions(self):
        plugin = dotnet.DotNetPlugin('test-part', self.options, self.project)
        _setup_dirs(plugin)
        plugin.build()

        self.assertThat(
            os.stat(os.path.join(plugin.installdir, 'test-app')).st_mode
            & 0o777, Equals(0o755))
Ejemplo n.º 4
0
 def test_sdk_in_path(self):
     plugin = dotnet.DotNetPlugin('test-part', self.options, self.project)
     self.assertThat(
         plugin.env(plugin.installdir),
         Contains('PATH={}:$PATH'.format(plugin._dotnet_sdk_dir)))
     # Be sure that the PATH doesn't leak into the final snap
     self.assertThat(plugin.env(self.project.stage_dir), Equals([]))
     self.assertThat(plugin.env(self.project.prime_dir), Equals([]))
Ejemplo n.º 5
0
    def test_pull_sdk(self):
        plugin = dotnet.DotNetPlugin('test-part', self.options, self.project)
        with mock.patch.object(sources.Tar,
                               'download',
                               return_value='test-sdk.tar'):
            plugin.pull()

        self.assertThat(
            os.path.join('parts', 'test-part', 'dotnet', 'sdk', 'test-sdk'),
            FileExists())
Ejemplo n.º 6
0
    def test_pull_sdk(self):
        plugin = dotnet.DotNetPlugin("test-part", self.options, self.project)
        with mock.patch.object(sources.Tar,
                               "download",
                               return_value="test-sdk.tar"):
            plugin.pull()

        self.assertThat(
            os.path.join("parts", "test-part", "dotnet", "sdk", "test-sdk"),
            FileExists(),
        )
Ejemplo n.º 7
0
    def test_build_commands(self):
        self.options.build_attributes = self.build_attributes
        plugin = dotnet.DotNetPlugin(
            'test-part', self.options, self.project)
        _setup_dirs(plugin)
        plugin.build()

        part_dir = os.path.join(self.path, 'parts', 'test-part')
        dotnet_command = os.path.join(part_dir, 'dotnet', 'sdk', 'dotnet')
        self.assertThat(
            self.mock_check_call.mock_calls, Equals([
                mock.call([
                    mock.ANY, mock.ANY, dotnet_command,
                    'build', '-c', self.configuration], cwd=mock.ANY),
                mock.call([
                    mock.ANY, mock.ANY, dotnet_command,
                    'publish', '-c', self.configuration,
                    '-o', plugin.installdir,
                    '--self-contained', '-r', 'linux-x64'], cwd=mock.ANY)]))
Ejemplo n.º 8
0
    def test_pull_sdk(self):
        with tarfile.open('test-sdk.tar', 'w') as test_sdk_tar:
            open('test-sdk', 'w').close()
            test_sdk_tar.add('test-sdk')
        with mock.patch.dict(
                    dotnet._SDKS_AMD64['2.0.0'],
                    {'checksum': 'sha256/{}'.format(
                        file_utils.calculate_hash(
                            'test-sdk.tar', algorithm='sha256'))}):
            plugin = dotnet.DotNetPlugin(
                'test-part', self.options, self.project)

        with mock.patch.object(
                sources.Tar, 'download', return_value='test-sdk.tar'):
            plugin.pull()

        self.assertThat(
            os.path.join('parts', 'test-part', 'dotnet', 'sdk', 'test-sdk'),
            FileExists())
Ejemplo n.º 9
0
 def test_clean_pull_removes_dotnet_dir(self):
     dotnet_dir = os.path.join("parts", "test-part", "dotnet", "sdk")
     os.makedirs(dotnet_dir)
     plugin = dotnet.DotNetPlugin("test-part", self.options, self.project)
     plugin.clean_pull()
     self.assertThat(dotnet_dir, Not(DirExists()))