package services import ( "context" "testing" "jd-book-uploader/models" ) func TestCreateStationery(t *testing.T) { // This test requires a running database // Skip if not available t.Skip("Skipping CreateStationery test - requires running database") ctx := context.Background() // This test would require: // 1. Database connection initialized // 2. Valid test data // 3. Cleanup after test req := &models.StationeryCreateRequest{ StationeryName: "Test Pen", Cost: 2.50, Price: 5.99, Discount: 0, Quantity: 200, Color: "Blue", Material: "Plastic", Dimensions: "15cm", Category: "Writing", Description: "A test pen", ImageURL: "https://example.com/image.png", } stationery, err := CreateStationery(ctx, req) if err != nil { t.Fatalf("CreateStationery() error = %v", err) } if stationery == nil { t.Fatal("CreateStationery() returned nil stationery") } if stationery.StationeryCode == "" { t.Error("CreateStationery() did not generate stationery_code") } if stationery.Slug == "" { t.Error("CreateStationery() did not generate slug") } if stationery.Slug != "test-pen" { t.Errorf("CreateStationery() slug = %q, want %q", stationery.Slug, "test-pen") } } func TestGetStationeryByCode(t *testing.T) { // This test requires a running database // Skip if not available t.Skip("Skipping GetStationeryByCode test - requires running database") ctx := context.Background() // This test would require: // 1. Database connection initialized // 2. A stationery item already in the database // 3. Valid stationery_code stationeryCode := "test-stationery-code" stationery, err := GetStationeryByCode(ctx, stationeryCode) if err != nil { t.Logf("GetStationeryByCode() error = %v (expected if stationery not found)", err) return } if stationery == nil { t.Error("GetStationeryByCode() returned nil stationery") } if stationery.StationeryCode != stationeryCode { t.Errorf("GetStationeryByCode() stationery_code = %q, want %q", stationery.StationeryCode, stationeryCode) } }