package models

import (
	"testing"

	"cloud.o-forge.io/core/oc-lib/models"
	"cloud.o-forge.io/core/oc-lib/tools"
	"github.com/stretchr/testify/assert"
)

func TestModel_ReturnsValidInstances(t *testing.T) {
	for name := range models.ModelsCatalog {
		t.Run(name, func(t *testing.T) {
			modelInt := tools.FromString(name)
			obj := models.Model(modelInt)
			assert.NotNil(t, obj, "Model() returned nil for valid model name %s", name)
		})
	}
}

func TestModel_UnknownModelReturnsNil(t *testing.T) {
	invalidModelInt := -9999 // unlikely to be valid
	obj := models.Model(invalidModelInt)
	assert.Nil(t, obj)
}

func TestGetModelsNames_ReturnsAllKeys(t *testing.T) {
	names := models.GetModelsNames()
	assert.Len(t, names, len(models.ModelsCatalog))

	seen := make(map[string]bool)
	for _, name := range names {
		seen[name] = true
	}
	for key := range models.ModelsCatalog {
		assert.Contains(t, seen, key)
	}
}
