package plugins

import (
	"testing"

	"github.com/WAH-ISHAN/backlist-npm/devops/internal/config"
)

func TestDockerPlugin_Name(t *testing.T) {
	p := NewDockerPlugin()
	if p.Name() != "docker" {
		t.Errorf("Expected name 'docker', got '%s'", p.Name())
	}
}

func TestKubernetesPlugin_Name(t *testing.T) {
	p := NewKubernetesPlugin()
	if p.Name() != "kubernetes" {
		t.Errorf("Expected name 'kubernetes', got '%s'", p.Name())
	}
}

func TestHelmPlugin_Name(t *testing.T) {
	p := NewHelmPlugin()
	if p.Name() != "helm" {
		t.Errorf("Expected name 'helm', got '%s'", p.Name())
	}
}

func TestTerraformPlugin_Name(t *testing.T) {
	p := NewTerraformPlugin()
	if p.Name() != "terraform" {
		t.Errorf("Expected name 'terraform', got '%s'", p.Name())
	}
}

func TestGitHubPlugin_Name(t *testing.T) {
	p := NewGitHubPlugin()
	if p.Name() != "github" {
		t.Errorf("Expected name 'github', got '%s'", p.Name())
	}
}

func TestDockerPlugin_Init(t *testing.T) {
	p := NewDockerPlugin()
	cfg := &config.Config{
		Project: config.ProjectConfig{Name: "test"},
		Docker:  config.DockerConfig{Image: "test-image"},
	}

	err := p.Init(cfg)
	if err != nil {
		t.Errorf("Init() error = %v", err)
	}

	if p.config != cfg {
		t.Error("Config not set correctly")
	}
}

func TestKubernetesPlugin_Init(t *testing.T) {
	p := NewKubernetesPlugin()
	cfg := &config.Config{
		Project: config.ProjectConfig{Name: "test"},
		Kubernetes: config.KubernetesConfig{
			Namespace: "test-ns",
		},
	}

	err := p.Init(cfg)
	if err != nil {
		t.Errorf("Init() error = %v", err)
	}

	if p.config != cfg {
		t.Error("Config not set correctly")
	}
}

func TestHelmPlugin_Init(t *testing.T) {
	p := NewHelmPlugin()
	cfg := &config.Config{
		Project: config.ProjectConfig{Name: "test"},
		Helm: config.HelmConfig{
			Chart:   "./charts/test",
			Release: "test-release",
		},
	}

	err := p.Init(cfg)
	if err != nil {
		t.Errorf("Init() error = %v", err)
	}

	if p.config != cfg {
		t.Error("Config not set correctly")
	}
}

func TestTerraformPlugin_Init(t *testing.T) {
	p := NewTerraformPlugin()
	cfg := &config.Config{
		Project: config.ProjectConfig{Name: "test"},
		Terraform: config.TerraformConfig{
			Backend: "s3",
		},
	}

	err := p.Init(cfg)
	if err != nil {
		t.Errorf("Init() error = %v", err)
	}

	if p.config != cfg {
		t.Error("Config not set correctly")
	}
}

func TestAWSPlugin_Name(t *testing.T) {
	p := NewAWSPlugin()
	if p.Name() != "aws" {
		t.Errorf("Expected name 'aws', got '%s'", p.Name())
	}
}

func TestAzurePlugin_Name(t *testing.T) {
	p := NewAzurePlugin()
	if p.Name() != "azure" {
		t.Errorf("Expected name 'azure', got '%s'", p.Name())
	}
}

func TestGCPPlugin_Name(t *testing.T) {
	p := NewGCPPlugin()
	if p.Name() != "gcp" {
		t.Errorf("Expected name 'gcp', got '%s'", p.Name())
	}
}

func TestGitLabPlugin_Name(t *testing.T) {
	p := NewGitLabPlugin()
	if p.Name() != "gitlab" {
		t.Errorf("Expected name 'gitlab', got '%s'", p.Name())
	}
}

func TestJenkinsPlugin_Name(t *testing.T) {
	p := NewJenkinsPlugin()
	if p.Name() != "jenkins" {
		t.Errorf("Expected name 'jenkins', got '%s'", p.Name())
	}
}
