def run_test(self, configuration, build_attributes): self.options.build_attributes = 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", configuration], cwd=mock.ANY), mock.call( [ dotnet_command, "publish", "-c", configuration, "-o", plugin.installdir, "--self-contained", "-r", "linux-x64", ], cwd=mock.ANY, ), ]), )
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), )
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([]))
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(), )
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()))