Creating unit tests for documentation bundle

Hi everyone,

I'm working on this issue and am implementing the unit test for it but I'm having trouble understanding everything. How can I change/examine the file structure for this test?

func testCrawlDiagnostics() throws {
        let workspace = DocumentationWorkspace()
        let context = try DocumentationContext(dataProvider: workspace)
        let tempURL = try createTemporaryDirectory().appendingPathComponent("unit-test.docc")
        let testBundleURL = Bundle.module.url(
            forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")!
        XCTAssert(FileManager.default.fileExists(atPath: testBundleURL.path))
        try FileManager.default.copyItem(at: testBundleURL, to: tempURL)
        let sidecarFile = tempURL.appendingPathComponent("documentation/")
        let source = """
        # ``MyKit/MyClass/myFunction()``

        myFunction abstract.

        ## Topics

        ### Invalid curation

        A few different curations that should each result in warnings.
        The first is a reference to the parent, the second is a reference to self, and the last is an unresolved reference.

         - ``MyKit``
         - ``myFunction()``
         - ``UnknownSymbol``
        try source.write(to: sidecarFile, atomically: true, encoding: .utf8)
        let dataProvider = try LocalFileSystemDataProvider(rootURL: tempURL)
        try workspace.registerProvider(dataProvider)
        var crawler = DocumentationCurator(in: context, bundle: workspace.bundles.values.first!)
        let mykit = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift))
        XCTAssertNoThrow(try crawler.crawlChildren(of: mykit.reference, prepareForCuration: { _ in }, relateNodes: { _, _ in }))
        let myClassProblems = crawler.problems.filter({ $0.diagnostic.source?.standardizedFileURL == sidecarFile.standardizedFileURL })
        XCTAssertEqual(myClassProblems.count, 1)
1 Like