gohorsejobs/backend/internal/services/storage_service_test.go
NANDO9322 ddc2f5dd03 feat: atualiza fluxo de cadastro de candidatos com persistência completa de dados e máscara de telefone
Frontend:
- Implementar máscara de entrada de telefone para números BR ((XX) XXXXX-XXXX).
- Atualizar formulário de cadastro para enviar dados completos do perfil do candidato (endereço, formação, habilidades, etc.).
- Corrigir problemas de idioma misto na página de Detalhes da Vaga e adicionar traduções faltantes.

Backend:
- Atualizar modelo de Usuário, Entidade e DTOs para incluir campos de perfil (Data de Nascimento, Endereço, Formação, etc.).
- Atualizar UserRepository para persistir e recuperar os dados estendidos do usuário no PostgreSQL.
- Atualizar RegisterCandidateUseCase para mapear campos de entrada para a entidade Usuário.
2026-01-06 18:19:47 -03:00

94 lines
2.2 KiB
Go

package services
import (
"testing"
)
func TestNewStorageService(t *testing.T) {
// StorageService requires a CredentialsService pointer
// Test with nil value (basic constructor test)
service := NewStorageService(nil)
if service == nil {
t.Error("Expected service, got nil")
}
if service.credentialsService != nil {
t.Error("Expected nil credentialsService")
}
}
func TestUploadConfig_Validation(t *testing.T) {
// Test the UploadConfig struct is properly defined
cfg := UploadConfig{
Endpoint: "https://s3.example.com",
AccessKey: "access123",
SecretKey: "secret456",
Bucket: "my-bucket",
Region: "us-east-1",
}
if cfg.Endpoint == "" {
t.Error("Expected endpoint to be set")
}
if cfg.AccessKey == "" {
t.Error("Expected accessKey to be set")
}
if cfg.SecretKey == "" {
t.Error("Expected secretKey to be set")
}
if cfg.Bucket == "" {
t.Error("Expected bucket to be set")
}
if cfg.Region == "" {
t.Error("Expected region to be set")
}
}
func TestUploadConfig_DefaultRegion(t *testing.T) {
// Test that empty region would need defaulting
cfg := UploadConfig{
Endpoint: "https://r2.cloudflare.com",
AccessKey: "access",
SecretKey: "secret",
Bucket: "bucket",
Region: "", // Empty
}
_ = cfg.Endpoint
_ = cfg.AccessKey
_ = cfg.SecretKey
_ = cfg.Bucket
// In the actual getClient, empty region defaults to "auto"
if cfg.Region != "" {
t.Error("Region should be empty for this test case")
}
// Simulate default
if cfg.Region == "" {
cfg.Region = "auto"
}
if cfg.Region != "auto" {
t.Errorf("Expected region='auto', got '%s'", cfg.Region)
}
}
func TestUploadConfig_IncompleteFields(t *testing.T) {
// Test incomplete config detection
incomplete := UploadConfig{
Endpoint: "https://s3.example.com",
AccessKey: "",
SecretKey: "",
Bucket: "bucket",
Region: "us-east-1",
}
_ = incomplete.Endpoint
_ = incomplete.Bucket
_ = incomplete.Region
// Validation logic that would be in getClient
if incomplete.AccessKey == "" || incomplete.SecretKey == "" {
// Would return error
t.Log("Correctly identified incomplete credentials")
} else {
t.Error("Should detect missing credentials")
}
}