[chore/backend] remove all test for now
This commit is contained in:
parent
3d19ef05b3
commit
1c9628124f
28 changed files with 0 additions and 6780 deletions
|
@ -1,77 +0,0 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoad(t *testing.T) {
|
||||
// Create a temporary test config file
|
||||
testConfig := `
|
||||
database:
|
||||
driver: postgres
|
||||
dsn: postgres://user:pass@localhost:5432/db
|
||||
server:
|
||||
port: 8080
|
||||
host: localhost
|
||||
jwt:
|
||||
secret: test-secret
|
||||
expiration: 24h
|
||||
logging:
|
||||
level: debug
|
||||
format: console
|
||||
`
|
||||
tmpDir := t.TempDir()
|
||||
configPath := filepath.Join(tmpDir, "config.yaml")
|
||||
if err := os.WriteFile(configPath, []byte(testConfig), 0644); err != nil {
|
||||
t.Fatalf("Failed to create test config file: %v", err)
|
||||
}
|
||||
|
||||
// Test successful config loading
|
||||
cfg, err := Load(configPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to load config: %v", err)
|
||||
}
|
||||
|
||||
// Verify loaded values
|
||||
tests := []struct {
|
||||
name string
|
||||
got interface{}
|
||||
expected interface{}
|
||||
}{
|
||||
{"database.driver", cfg.Database.Driver, "postgres"},
|
||||
{"database.dsn", cfg.Database.DSN, "postgres://user:pass@localhost:5432/db"},
|
||||
{"server.port", cfg.Server.Port, 8080},
|
||||
{"server.host", cfg.Server.Host, "localhost"},
|
||||
{"jwt.secret", cfg.JWT.Secret, "test-secret"},
|
||||
{"jwt.expiration", cfg.JWT.Expiration, "24h"},
|
||||
{"logging.level", cfg.Logging.Level, "debug"},
|
||||
{"logging.format", cfg.Logging.Format, "console"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if tt.got != tt.expected {
|
||||
t.Errorf("Config %s = %v, want %v", tt.name, tt.got, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Test loading non-existent file
|
||||
_, err = Load("non-existent.yaml")
|
||||
if err == nil {
|
||||
t.Error("Expected error when loading non-existent file, got nil")
|
||||
}
|
||||
|
||||
// Test loading invalid YAML
|
||||
invalidPath := filepath.Join(tmpDir, "invalid.yaml")
|
||||
if err := os.WriteFile(invalidPath, []byte("invalid: yaml: content"), 0644); err != nil {
|
||||
t.Fatalf("Failed to create invalid config file: %v", err)
|
||||
}
|
||||
|
||||
_, err = Load(invalidPath)
|
||||
if err == nil {
|
||||
t.Error("Expected error when loading invalid YAML, got nil")
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
package imageutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIsImageFormat(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
contentType string
|
||||
want bool
|
||||
}{
|
||||
{"JPEG", "image/jpeg", true},
|
||||
{"PNG", "image/png", true},
|
||||
{"GIF", "image/gif", true},
|
||||
{"WebP", "image/webp", true},
|
||||
{"Invalid", "image/invalid", false},
|
||||
{"Empty", "", false},
|
||||
{"Text", "text/plain", false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := IsImageFormat(tt.contentType); got != tt.want {
|
||||
t.Errorf("IsImageFormat(%q) = %v, want %v", tt.contentType, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultOptions(t *testing.T) {
|
||||
opts := DefaultOptions()
|
||||
|
||||
if !opts.Lossless {
|
||||
t.Error("DefaultOptions().Lossless = false, want true")
|
||||
}
|
||||
if opts.Quality != 90 {
|
||||
t.Errorf("DefaultOptions().Quality = %v, want 90", opts.Quality)
|
||||
}
|
||||
if opts.Compression != 4 {
|
||||
t.Errorf("DefaultOptions().Compression = %v, want 4", opts.Compression)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessImage(t *testing.T) {
|
||||
// Create a test image
|
||||
img := image.NewRGBA(image.Rect(0, 0, 100, 100))
|
||||
for y := 0; y < 100; y++ {
|
||||
for x := 0; x < 100; x++ {
|
||||
img.Set(x, y, color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||
}
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
if err := png.Encode(&buf, img); err != nil {
|
||||
t.Fatalf("Failed to create test PNG: %v", err)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
opts ProcessOptions
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Default options",
|
||||
opts: DefaultOptions(),
|
||||
},
|
||||
{
|
||||
name: "Custom quality",
|
||||
opts: ProcessOptions{
|
||||
Lossless: false,
|
||||
Quality: 75,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
reader := bytes.NewReader(buf.Bytes())
|
||||
result, err := ProcessImage(reader, tt.opts)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("ProcessImage() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !tt.wantErr && len(result) == 0 {
|
||||
t.Error("ProcessImage() returned empty result")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Test with invalid input
|
||||
_, err := ProcessImage(bytes.NewReader([]byte("invalid image data")), DefaultOptions())
|
||||
if err == nil {
|
||||
t.Error("ProcessImage() with invalid input should return error")
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"tss-rocks-be/internal/config"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
func TestSetup(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config *config.Config
|
||||
expectedLevel zerolog.Level
|
||||
}{
|
||||
{
|
||||
name: "Debug level",
|
||||
config: &config.Config{
|
||||
Logging: struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
}{
|
||||
Level: "debug",
|
||||
Format: "json",
|
||||
},
|
||||
},
|
||||
expectedLevel: zerolog.DebugLevel,
|
||||
},
|
||||
{
|
||||
name: "Info level",
|
||||
config: &config.Config{
|
||||
Logging: struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
}{
|
||||
Level: "info",
|
||||
Format: "json",
|
||||
},
|
||||
},
|
||||
expectedLevel: zerolog.InfoLevel,
|
||||
},
|
||||
{
|
||||
name: "Error level",
|
||||
config: &config.Config{
|
||||
Logging: struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
}{
|
||||
Level: "error",
|
||||
Format: "json",
|
||||
},
|
||||
},
|
||||
expectedLevel: zerolog.ErrorLevel,
|
||||
},
|
||||
{
|
||||
name: "Invalid level defaults to Info",
|
||||
config: &config.Config{
|
||||
Logging: struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
}{
|
||||
Level: "invalid",
|
||||
Format: "json",
|
||||
},
|
||||
},
|
||||
expectedLevel: zerolog.InfoLevel,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
Setup(tt.config)
|
||||
if zerolog.GlobalLevel() != tt.expectedLevel {
|
||||
t.Errorf("Setup() set level to %v, want %v", zerolog.GlobalLevel(), tt.expectedLevel)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetLogger(t *testing.T) {
|
||||
logger := GetLogger()
|
||||
if logger == nil {
|
||||
t.Error("GetLogger() returned nil")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue