@@ -98,6 +98,40 @@ func TestDocsCommand_BuildsRAGIndexByDefault(t *testing.T) {
9898 }
9999}
100100
101+ func TestDocsCommand_BuildsNamespaceIndexes (t * testing.T ) {
102+ deps , stdout , stderr , db := setupDocsTest (t )
103+
104+ db .Create (& model.Node {
105+ Namespace : "alpha" ,
106+ QualifiedName : "pkg.Main" ,
107+ Kind : model .NodeKindFunction ,
108+ Name : "Main" ,
109+ FilePath : "pkg/main.go" ,
110+ StartLine : 1 , EndLine : 5 ,
111+ Hash : "h1" , Language : "go" ,
112+ })
113+
114+ outDir := t .TempDir ()
115+ indexDir := t .TempDir ()
116+ if err := executeCmd (deps , stdout , stderr , "--namespace" , "alpha" , "docs" , "--out" , outDir , "--rag-index-dir" , indexDir ); err != nil {
117+ t .Fatalf ("docs: %v" , err )
118+ }
119+
120+ if _ , err := os .Stat (filepath .Join (indexDir , "alpha" , "doc-index.json" )); err != nil {
121+ t .Fatalf ("expected namespace doc-index.json to be created: %v" , err )
122+ }
123+ if _ , err := os .Stat (filepath .Join (indexDir , "alpha" , "wiki-index.json" )); err != nil {
124+ t .Fatalf ("expected namespace wiki-index.json to be created: %v" , err )
125+ }
126+ if _ , err := os .Stat (filepath .Join (indexDir , "doc-index.json" )); ! os .IsNotExist (err ) {
127+ t .Fatalf ("default doc-index.json should not be written for named namespace, stat err=%v" , err )
128+ }
129+ out := stdout .String ()
130+ if ! strings .Contains (out , "Wiki index written:" ) || ! strings .Contains (out , "RAG index written:" ) {
131+ t .Fatalf ("expected index output, got:\n %s" , out )
132+ }
133+ }
134+
101135func TestDocsCommand_RAGFlagCanDisableIndexBuild (t * testing.T ) {
102136 deps , stdout , stderr , db := setupDocsTest (t )
103137
0 commit comments