package services

import "testing"

// TestNameArtifactsValidate guards the seed system-default compositions
// against their own catalogs — a typo'd variable in a seed composition (a key
// the catalog doesn't declare) fails here rather than silently rendering
// nothing in production.
func TestNameArtifactsValidate(t *testing.T) {
	for id, art := range nameArtifacts {
		if art.ID != id {
			t.Errorf("artifact %q has mismatched ID %q", id, art.ID)
		}
		if art.Target == nil {
			t.Errorf("artifact %q has nil target", id)
		}
		if err := art.SystemDefault.Validate(art.Catalog); err != nil {
			t.Errorf("artifact %q system default invalid: %v", id, err)
		}
	}
}

// TestNameArtifactLookup covers the registry accessor.
func TestNameArtifactLookup(t *testing.T) {
	if _, ok := NameArtifact(ArtifactSubmissionDraftTitle); !ok {
		t.Errorf("draft-title artifact not registered")
	}
	if _, ok := NameArtifact(ArtifactSubmissionDocxFilename); !ok {
		t.Errorf("docx-filename artifact not registered")
	}
	if _, ok := NameArtifact("nonexistent"); ok {
		t.Errorf("lookup of unknown artifact returned ok")
	}
}
