// This file holds the end-to-end suite for the documentation importer: analyse a // real project tree on disk, render a page, merge it through the storage engine, // and read it back over HTTP. No mocks anywhere -- if the pipeline breaks, these // tests break. package tests import ( "net/http" "os" "path/filepath" "strings" "testing" "go-doc/docgen" ) // getJSON fetches a resource as JSON, which is how the frontend reads pages. // The API negotiates with ?format=json rather than the Accept header. func (h *harness) getJSON(path string) map[string]any { h.t.Helper() if !strings.Contains(path, "?") { path += "?format=json" } payload := h.expectStatus(http.MethodGet, path, "", "", http.StatusOK) return decodeJSON[map[string]any](h.t, payload) } func TestIntegrationDocgenImport(t *testing.T) { t.Parallel() h := newHarness(t) workspace := t.TempDir() writeFixtureProject(t, filepath.Join(workspace, "go-fixture")) project, err := docgen.Analyze("go-fixture", filepath.Join(workspace, "go-fixture")) if err != nil { t.Fatalf("integration: analyse fixture: %v", err) } page, err := docgen.Render(project) if err != nil { t.Fatalf("integration: render fixture: %v", err) } slug, err := h.engine.SaveDoc(project.Name, page) if err != nil { t.Fatalf("integration: import page: %v", err) } if slug != "go-fixture" { t.Fatalf("integration: expected slug go-fixture, got %q", slug) } // The page lands on disk exactly once, wrapped in generated markers that // record which project it came from. onDisk := string(requireFile(t, filepath.Join(h.docsDir, "go-fixture.md"))) if !strings.HasPrefix(onDisk, "