package main

import (
	"fmt"
	"gitea.pena/PenaSide/common/validate"
	minioDal "gitea.pena/PenaSide/heruvym/internal/repository/minio"
	"github.com/stretchr/testify/assert"
	"os"
	"testing"
)

func TestLoadConfig(t *testing.T) {
	envVars := map[string]string{
		"MONGO_URL":           "mongodb://test:test@localhost:27020/",
		"MONGO_DB_NAME":       "admin",
		"IS_PROD":             "false",
		"S3Endpoint":          "localhost:9000",
		"S3_ACCESS_KEY":       "minioadmin",
		"S3_SECRET_KEY":       "minioadmin",
		"S3_TOKEN":            "",
		"REDIS_HOST":          "localhost:6379",
		"REDIS_PASSWORD":      "admin",
		"REDIS_DB":            "2",
		"CLIENT_HTTP_URL":     "localhost:3000",
		"ADMIN_HTTP_URL":      "localhost:3001",
		"TELEGRAM_TOKEN":      "7127966184:AAG1steOCH4wDvHRe9QcsXJPS4dWRyRYsqg",
		"TELEGRAM_CHANNEL_ID": "1001344671794",
	}

	for key, value := range envVars {
		os.Setenv(key, value)
	}

	cfg, err := loadConfig()
	assert.Nil(t, err)

	fmt.Println(cfg)
}

func TestValidateS3(t *testing.T) {
	err := validate.ValidateS3(validate.ValidateS3Deps{S3Endpoint: "localhost:9000", S3AccessKey: "minioadmin", S3SecretKey: "minioadmin", S3Token: "", BucketName: minioDal.Bucket, IsProd: false})
	assert.NoError(t, err)
}
