@@ -37,27 +37,32 @@ func TestPublishCoreAPIRejectsStaleNonFastForwardPush(t *testing.T) {
3737
3838 firstReference := filepath .Join (temporary , "first-api.json" )
3939 secondReference := filepath .Join (temporary , "second-api.json" )
40+ firstCatalog := filepath .Join (temporary , "first-catalog.json" )
41+ secondCatalog := filepath .Join (temporary , "second-catalog.json" )
4042 writeReference (t , firstReference , "2.0.0-alpha.1" )
4143 writeReference (t , secondReference , "2.0.0-alpha.2" )
44+ writeCatalog (t , firstCatalog , "2.0.0-alpha.1" )
45+ writeCatalog (t , secondCatalog , "2.0.0-alpha.2" )
4246
4347 publish := filepath .Join (root , "scripts" , "publish-core-api.sh" )
44- runPublish (t , root , publish , firstReference , first , remote , true )
48+ runPublish (t , root , publish , firstReference , firstCatalog , first , remote , true )
4549 remoteAfterFirst := strings .TrimSpace (git (t , temporary , "--git-dir" , remote , "rev-parse" , "refs/heads/gh-pages" ))
4650
47- runPublish (t , root , publish , secondReference , second , remote , false )
51+ runPublish (t , root , publish , secondReference , secondCatalog , second , remote , false )
4852 remoteAfterStale := strings .TrimSpace (git (t , temporary , "--git-dir" , remote , "rev-parse" , "refs/heads/gh-pages" ))
4953 if remoteAfterStale != remoteAfterFirst {
5054 t .Fatalf ("stale push changed published history: before=%s after=%s" , remoteAfterFirst , remoteAfterStale )
5155 }
5256
5357 assertContent (t , filepath .Join (first , ".gitignore" ), "public\n " )
5458 assertContent (t , filepath .Join (first , "versions" , "2.0.0-alpha.1" , "api.json" ), string (read (t , firstReference )))
59+ assertContent (t , filepath .Join (first , "versions" , "2.0.0-alpha.1" , "catalog.json" ), string (read (t , firstCatalog )))
5560}
5661
57- func runPublish (t * testing.T , root , script , reference , pages , remote string , wantSuccess bool ) {
62+ func runPublish (t * testing.T , root , script , reference , catalog , pages , remote string , wantSuccess bool ) {
5863 t .Helper ()
5964
60- command := exec .Command (script , reference , pages , remote , "gh-pages" )
65+ command := exec .Command (script , reference , catalog , pages , remote , "gh-pages" )
6166 command .Dir = root
6267 command .Env = append (os .Environ (), "GOWORK=off" )
6368 output , err := command .CombinedOutput ()
@@ -74,6 +79,32 @@ func runPublish(t *testing.T, root, script, reference, pages, remote string, wan
7479 }
7580}
7681
82+ func writeCatalog (t * testing.T , path , version string ) {
83+ t .Helper ()
84+
85+ catalog := map [string ]any {
86+ "schemaVersion" : 1 ,
87+ "id" : "montferret/core" ,
88+ "version" : version ,
89+ "categories" : []any {map [string ]any {
90+ "id" : "utils" ,
91+ "title" : "Utilities" ,
92+ "description" : "General utility functions." ,
93+ "functions" : []string {"PING" },
94+ }},
95+ "namespaceRoots" : []string {},
96+ }
97+
98+ data , err := json .MarshalIndent (catalog , "" , " " )
99+ if err != nil {
100+ t .Fatal (err )
101+ }
102+
103+ if err := os .WriteFile (path , append (data , '\n' ), 0o644 ); err != nil {
104+ t .Fatal (err )
105+ }
106+ }
107+
77108func writeReference (t * testing.T , path , version string ) {
78109 t .Helper ()
79110
0 commit comments