@@ -405,6 +405,97 @@ registry:
405405 assert .Equal (t , "Another test server" , catalog .Servers [1 ].Snapshot .Server .Description )
406406}
407407
408+ func TestCreateFromLegacyCatalogWithPociServers (t * testing.T ) {
409+ dao := setupTestDB (t )
410+ ctx := t .Context ()
411+
412+ // Create a temporary legacy catalog file with server, remote, and poci types
413+ tempDir := t .TempDir ()
414+ catalogFile := filepath .Join (tempDir , "test-catalog.yaml" )
415+
416+ legacyCatalogYAML := `name: test-catalog
417+ registry:
418+ my-server:
419+ title: "My Server"
420+ type: "server"
421+ image: "docker/test-server:latest"
422+ description: "A regular server"
423+ my-remote:
424+ title: "My Remote"
425+ type: "remote"
426+ description: "A remote server"
427+ remote:
428+ url: "https://remote.example.com/mcp"
429+ curl:
430+ title: "Curl"
431+ type: "poci"
432+ description: "Standard curl tool."
433+ tools:
434+ - name: curl
435+ description: "Run a curl command."
436+ container:
437+ image: "alpine/curl"
438+ command:
439+ - "{{args|into}}"
440+ ffmpeg:
441+ title: "FFmpeg"
442+ type: "poci"
443+ description: "Use ffmpeg to process video files."
444+ tools:
445+ - name: ffmpeg
446+ description: "run the ffmpeg command"
447+ container:
448+ image: "linuxserver/ffmpeg:version-7.1-cli"
449+ command:
450+ - "{{args|into}}"
451+ `
452+
453+ err := os .WriteFile (catalogFile , []byte (legacyCatalogYAML ), 0o644 )
454+ require .NoError (t , err )
455+
456+ // Create catalog from legacy catalog
457+ output := captureStdout (t , func () {
458+ err := Create (ctx , dao , getMockRegistryClient (), getMockOciService (), "test/poci-test:latest" , []string {}, "" , catalogFile , "" , "Poci Test Catalog" , false )
459+ require .NoError (t , err )
460+ })
461+
462+ assert .Contains (t , output , "Catalog test/poci-test:latest created" )
463+
464+ // Verify the catalog was created
465+ catalogs , err := dao .ListCatalogs (ctx )
466+ require .NoError (t , err )
467+ assert .Len (t , catalogs , 1 )
468+
469+ catalog := NewFromDb (& catalogs [0 ])
470+ assert .Equal (t , "Poci Test Catalog" , catalog .Title )
471+ assert .Len (t , catalog .Servers , 4 )
472+
473+ // Verify all server types are present (order may vary due to map iteration)
474+ serversByName := map [string ]Server {}
475+ for _ , s := range catalog .Servers {
476+ serversByName [s .Snapshot .Server .Name ] = s
477+ }
478+
479+ // Verify poci servers
480+ curlServer := serversByName ["curl" ]
481+ assert .Equal (t , workingset .ServerTypePoci , curlServer .Type )
482+ assert .Equal (t , "Curl" , curlServer .Snapshot .Server .Title )
483+ assert .Equal (t , "Standard curl tool." , curlServer .Snapshot .Server .Description )
484+ assert .Empty (t , curlServer .Image )
485+
486+ ffmpegServer := serversByName ["ffmpeg" ]
487+ assert .Equal (t , workingset .ServerTypePoci , ffmpegServer .Type )
488+ assert .Equal (t , "FFmpeg" , ffmpegServer .Snapshot .Server .Title )
489+ assert .Empty (t , ffmpegServer .Image )
490+
491+ // Verify other types still work
492+ remoteServer := serversByName ["my-remote" ]
493+ assert .Equal (t , workingset .ServerTypeRemote , remoteServer .Type )
494+
495+ imageServer := serversByName ["my-server" ]
496+ assert .Equal (t , workingset .ServerTypeImage , imageServer .Type )
497+ }
498+
408499func TestCreateFromLegacyCatalogWithRemoveExistingWithSameContent (t * testing.T ) {
409500 dao := setupTestDB (t )
410501 ctx := t .Context ()
0 commit comments