- 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>
61 lines
1.4 KiB
Go
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")
|
|
}
|
|
}
|