Example #1
0
    def test_build(self):
        class Options:
            source = "dir"
            crystal_channel = "latest/stable"

        plugin = crystal.CrystalPlugin("test-part", Options(), self.project)

        # fake binaries being built
        self.useFixture(
            fixtures.MockPatch("snapcraft.internal.elf.ElfFile",
                               side_effect=MockElfFile))
        binaries = ["foo", "bar"]
        bin_dir = os.path.join(plugin.builddir, "bin")
        os.makedirs(bin_dir)
        for b in binaries:
            open(os.path.join(bin_dir, b), "w").close()

        plugin.build()

        self.fake_run.mock.assert_has_calls([
            mock.call(["shards", "install", "--production"],
                      cwd=plugin.builddir),
            mock.call(["shards", "build", "--production"],
                      cwd=plugin.builddir),
        ])
        self.assertThat(self.fake_run.mock.call_count, Equals(2))

        for b in binaries:
            self.assertThat(os.path.join(plugin.installdir, "bin", b),
                            FileExists())
Example #2
0
    def test_build_no_targets(self):
        class Options:
            source = "dir"
            crystal_channel = "latest/stable"

        plugin = crystal.CrystalPlugin("test-part", Options(), self.project)

        self.assertRaises(errors.SnapcraftEnvironmentError, plugin.build)
Example #3
0
    def test_pull(self):
        class Options:
            source = "dir"
            crystal_channel = "latest/stable"

        plugin = crystal.CrystalPlugin("test-part", Options(), self.project)

        plugin.pull()

        self.fake_run.mock.assert_not_called()