veza/veza-backend-api/internal/handlers/payout_handler_test.go
senke 38530b5a52 feat(v0.12.0): F252-F254 marketplace service enhancements
- F252: Enable download count decrement on GetDownloadURL
- F253: Differentiated commission rates (creator 15%, premium 10%)
- F254: Seller balance tracking, payout scheduling, manual payout request
- Enforce 14-day refund window on RefundOrder
- Credit seller balance on completed sales
- New payout handler with balance/payouts/request endpoints
- 15 new tests (payout, refund window, commission)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 18:52:06 +01:00

61 lines
1.4 KiB
Go

package handlers
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
)
func TestGetSellerBalance_NoAuth(t *testing.T) {
gin.SetMode(gin.TestMode)
r := gin.New()
r.GET("/sell/marketplace-balance", func(c *gin.Context) {
handler := &PayoutHandler{}
handler.GetSellerBalance(c)
})
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/sell/marketplace-balance", nil)
r.ServeHTTP(w, req)
// Without auth context, GetUserIDUUID returns false → no response body set by handler
if w.Code == http.StatusOK {
t.Error("expected non-200 when no auth context")
}
}
func TestGetPayoutHistory_NoAuth(t *testing.T) {
gin.SetMode(gin.TestMode)
r := gin.New()
r.GET("/sell/payouts", func(c *gin.Context) {
handler := &PayoutHandler{}
handler.GetPayoutHistory(c)
})
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/sell/payouts", nil)
r.ServeHTTP(w, req)
if w.Code == http.StatusOK {
t.Error("expected non-200 when no auth context")
}
}
func TestRequestPayout_NoAuth(t *testing.T) {
gin.SetMode(gin.TestMode)
r := gin.New()
r.POST("/sell/payouts/request", func(c *gin.Context) {
handler := &PayoutHandler{}
handler.RequestPayout(c)
})
w := httptest.NewRecorder()
req, _ := http.NewRequest("POST", "/sell/payouts/request", nil)
r.ServeHTTP(w, req)
if w.Code == http.StatusOK {
t.Error("expected non-200 when no auth context")
}
}