- Remove backend Medusa.js (TypeScript) e substitui pelo backend Go (saveinmed-performance-core) - Corrige testes auth.test.ts: alinha paths de API (v1/ sem barra inicial) e campo access_token - Corrige GroupedProductCard.test.tsx: ajusta distância formatada (toFixed) e troca userEvent por fireEvent com fakeTimers - Corrige AuthContext.test.tsx: usa vi.hoisted() para mocks e corrige parênteses no waitFor Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67 lines
1.8 KiB
Go
67 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
"log"
|
|
|
|
_ "github.com/jackc/pgx/v5/stdlib"
|
|
)
|
|
|
|
func main() {
|
|
// Using the correct port 55432 found in .env
|
|
connStr := "postgres://postgres:123@localhost:55432/saveinmed?sslmode=disable"
|
|
|
|
log.Printf("Connecting to DB at %s...", connStr)
|
|
db, err := sql.Open("pgx", connStr)
|
|
if err != nil {
|
|
log.Fatalf("Failed to open DB: %v", err)
|
|
}
|
|
defer db.Close()
|
|
|
|
if err := db.Ping(); err != nil {
|
|
log.Fatalf("Failed to ping DB: %v", err)
|
|
}
|
|
log.Println("Connected successfully!")
|
|
|
|
id := "019be7a2-7727-7536-bee6-1ef05b464f3d"
|
|
fmt.Printf("Checking Product ID: %s\n", id)
|
|
|
|
var count int
|
|
err = db.QueryRow("SELECT count(*) FROM products WHERE id = $1", id).Scan(&count)
|
|
if err != nil {
|
|
log.Printf("Query count failed: %v", err)
|
|
}
|
|
fmt.Printf("Count: %d\n", count)
|
|
|
|
if count > 0 {
|
|
var name string
|
|
var batch sql.NullString
|
|
// Check columns that might cause scan errors if null
|
|
// Also check stock and expires_at
|
|
var stock sql.NullInt64
|
|
var expiresAt sql.NullTime
|
|
|
|
err = db.QueryRow("SELECT name, batch, stock, expires_at FROM products WHERE id = $1", id).Scan(&name, &batch, &stock, &expiresAt)
|
|
if err != nil {
|
|
log.Printf("Select details failed: %v", err)
|
|
} else {
|
|
fmt.Printf("Found: Name=%s\n", name)
|
|
fmt.Printf("Batch: Valid=%v, String=%v\n", batch.Valid, batch.String)
|
|
fmt.Printf("Stock: Valid=%v, Int64=%v\n", stock.Valid, stock.Int64)
|
|
fmt.Printf("ExpiresAt: Valid=%v, Time=%v\n", expiresAt.Valid, expiresAt.Time)
|
|
}
|
|
} else {
|
|
fmt.Println("Product NOT FOUND in DB. Listing random 5 products:")
|
|
rows, err := db.Query("SELECT id, name FROM products LIMIT 5")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer rows.Close()
|
|
for rows.Next() {
|
|
var pid, pname string
|
|
rows.Scan(&pid, &pname)
|
|
fmt.Printf("- %s: %s\n", pid, pname)
|
|
}
|
|
}
|
|
}
|