package docs

import (
	"strings"
	"testing"

	"github.com/swaggo/swag"
)

// ─── SwaggerInfo temel alanları ──────────────────────────────────────────────

func TestSwaggerInfo_NotNil(t *testing.T) {
	if SwaggerInfo == nil {
		t.Fatal("SwaggerInfo must not be nil")
	}
}

func TestSwaggerInfo_Title(t *testing.T) {
	if SwaggerInfo.Title == "" {
		t.Fatal("SwaggerInfo.Title must not be empty")
	}
}

func TestSwaggerInfo_Version(t *testing.T) {
	if SwaggerInfo.Version == "" {
		t.Fatal("SwaggerInfo.Version must not be empty")
	}
}

func TestSwaggerInfo_BasePath(t *testing.T) {
	if SwaggerInfo.BasePath == "" {
		t.Fatal("SwaggerInfo.BasePath must not be empty")
	}
}

func TestSwaggerInfo_TemplateNotEmpty(t *testing.T) {
	if SwaggerInfo.SwaggerTemplate == "" {
		t.Fatal("SwaggerInfo.SwaggerTemplate must not be empty")
	}
}

// ─── Şablon içerik doğrulamaları ─────────────────────────────────────────────

func TestSwaggerInfo_TemplateContainsAuthLogin(t *testing.T) {
	if !strings.Contains(SwaggerInfo.SwaggerTemplate, "/auth/login") {
		t.Fatal("swagger template must contain /auth/login path")
	}
}

func TestSwaggerInfo_TemplateContainsImagesPath(t *testing.T) {
	if !strings.Contains(SwaggerInfo.SwaggerTemplate, "/images") {
		t.Fatal("swagger template must contain /images path")
	}
}

func TestSwaggerInfo_TemplateContainsBearerAuth(t *testing.T) {
	if !strings.Contains(SwaggerInfo.SwaggerTemplate, "BearerAuth") {
		t.Fatal("swagger template must define BearerAuth security scheme")
	}
}

// ─── Swaggo registry kaydı ───────────────────────────────────────────────────

func TestSwaggerInfo_RegisteredInSwaggo(t *testing.T) {
	spec := swag.GetSwagger(SwaggerInfo.InstanceName())
	if spec == nil {
		t.Fatalf("SwaggerInfo not registered under name %q", SwaggerInfo.InstanceName())
	}
}

func TestSwaggerInfo_InstanceNameMatchesTitle(t *testing.T) {
	if SwaggerInfo.InstanceName() == "" {
		t.Fatal("InstanceName must not be empty")
	}
}
