package operator

import (
	"context"
	"testing"

	"github.com/stretchr/testify/assert"

	"github.com/pfeifferj/container-mom-go/pkg/config"
)

func TestOperator(t *testing.T) {
	// Create test config
	cfg := &config.Config{
		ListenAddr: ":8081",
		MongoURI:   "mongodb://localhost:27017",
	}

	// Create operator
	op := New(cfg, nil)
	assert.NotNil(t, op)

	// Test deployment trigger
	err := op.TriggerDeploymentReconcile(context.Background(), "test-deployment")
	assert.Error(t, err) // Should fail because deployment doesn't exist

	// Test MongoDB connection
	client := op.GetMongoDB()
	assert.NotNil(t, client)
	err = client.Ping(context.Background(), nil)
	assert.NoError(t, err)
}

func TestOperatorHealth(t *testing.T) {
	// Create test config
	cfg := &config.Config{
		ListenAddr: ":8081",
		MongoURI:   "mongodb://localhost:27017",
	}

	// Create operator
	op := New(cfg, nil)
	assert.NotNil(t, op)

	// Test health check
	err := op.GetMongoDB().Ping(context.Background(), nil)
	assert.NoError(t, err)
}
