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