示例#1
0
    def test_node_modules_file_with_source_is_used(self):
        """
        If someone has uploaded node_modules, files in there should be treated like
        any other files (in other words, they should land in the cache with no errors).
        """

        project = self.create_project()
        release = self.create_release(project=project, version="12.31.12")

        abs_path = "app:///../node_modules/some-package/index.js"
        self.create_release_file(release=release, name=abs_path)

        processor = JavaScriptStacktraceProcessor(
            data={"release": release.version},
            stacktrace_infos=None,
            project=project)
        # in real life the preprocess step will pull release out of the data
        # dictionary passed to the JavaScriptStacktraceProcessor constructor,
        # but since this is just a unit test, we have to set it manually
        processor.release = release

        processor.cache_source(abs_path)

        # file is cached, no errors are generated
        assert processor.cache.get(abs_path)
        assert len(processor.cache.get_errors(abs_path)) == 0
示例#2
0
    def test_node_modules_file_with_source_but_no_map_records_error(self, mock_discover_sourcemap):
        """
        If someone has uploaded node_modules, but is missing maps, it should complain
        so that they either a) upload the maps, or b) don't upload the source files.
        """

        map_url = "app:///../node_modules/some-package/index.js.map"
        mock_discover_sourcemap.return_value = map_url

        project = self.create_project()
        release = self.create_release(project=project, version="12.31.12")

        abs_path = "app:///../node_modules/some-package/index.js"
        self.create_release_file(release=release, name=abs_path)

        processor = JavaScriptStacktraceProcessor(
            data={"release": release.version}, stacktrace_infos=None, project=project
        )
        # in real life the preprocess step will pull release out of the data
        # dictionary passed to the JavaScriptStacktraceProcessor constructor,
        # but since this is just a unit test, we have to set it manually
        processor.release = release

        # before caching, no errors
        assert len(processor.cache.get_errors(abs_path)) == 0

        processor.cache_source(abs_path)

        # now we have an error
        assert len(processor.cache.get_errors(abs_path)) == 1
        assert processor.cache.get_errors(abs_path)[0] == {"url": map_url, "type": "js_no_source"}