fix plugin manifest registration upsert
This commit is contained in:
@@ -1605,16 +1605,26 @@ func TestCoreServiceRejectsArbitrarySQLBridgeInputBeforeJob(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceRejectsDuplicateGamePluginManifest(t *testing.T) {
|
||||
func TestCoreServiceUpsertsDuplicateGamePluginManifest(t *testing.T) {
|
||||
svc := newTestCoreService()
|
||||
registration := validPluginManifestRegistration()
|
||||
if _, err := svc.RegisterGamePluginManifest(registration); err != nil {
|
||||
t.Fatalf("register first manifest: %v", err)
|
||||
}
|
||||
|
||||
_, err := svc.RegisterGamePluginManifest(registration)
|
||||
if !errors.Is(err, repo.ErrDuplicate) {
|
||||
t.Fatalf("expected duplicate plugin registration, got %v", err)
|
||||
registration.Manifest.Version = "0.1.1"
|
||||
registration.Manifest.Description = "Development plugin refreshed"
|
||||
registration.ManifestRef = "artifact://manifests/game.example/0.1.1"
|
||||
updated, err := svc.RegisterGamePluginManifest(registration)
|
||||
if err != nil {
|
||||
t.Fatalf("upsert manifest: %v", err)
|
||||
}
|
||||
if updated.ID != "game.example" || updated.Version != "0.1.1" || updated.ManifestRef != "artifact://manifests/game.example/0.1.1" {
|
||||
t.Fatalf("expected existing plugin to update in place, got %+v", updated)
|
||||
}
|
||||
listed, err := svc.ListGamePlugins(domain.GamePluginFilter{ServerType: "example", Status: domain.GamePluginStatusInstalled})
|
||||
if err != nil || len(listed) != 1 || listed[0].ID != "game.example" || listed[0].Version != "0.1.1" {
|
||||
t.Fatalf("expected one refreshed plugin after upsert, listed=%+v err=%v", listed, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user