Revert "feat(loyalty): EnakPoint & EnakCoin" (#32)
This reverts merge commit645da30, returning main tof0ff59f. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
645da3048e
commit
4e24f9bbb0
@@ -1,43 +0,0 @@
|
||||
package validator
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"apskel-pos-be/internal/constants"
|
||||
"apskel-pos-be/internal/contract"
|
||||
)
|
||||
|
||||
func TestWalletValidator_AdjustRequest(t *testing.T) {
|
||||
v := NewWalletValidator()
|
||||
|
||||
ok := &contract.AdjustCustomerWalletRequest{Currency: " point ", Amount: -25, Reason: " komplain #45 "}
|
||||
err, _ := v.ValidateAdjustRequest(ok)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, constants.WalletCurrencyPoint, ok.Currency, "currency is normalised")
|
||||
assert.Equal(t, "komplain #45", ok.Reason, "reason is trimmed")
|
||||
|
||||
legit := &contract.AdjustCustomerWalletRequest{Currency: "COIN", Amount: 5, Reason: "Bayar tunai tapi poin tidak masuk"}
|
||||
err, _ = v.ValidateAdjustRequest(legit)
|
||||
assert.NoError(t, err, "mentioning a cash payment is not a cash-out")
|
||||
|
||||
for name, req := range map[string]*contract.AdjustCustomerWalletRequest{
|
||||
"nil": nil,
|
||||
"no currency": {Amount: 5, Reason: "x"},
|
||||
"unknown currency": {Currency: "GOLD", Amount: 5, Reason: "x"},
|
||||
"zero amount": {Currency: "POINT", Amount: 0, Reason: "x"},
|
||||
"no reason": {Currency: "POINT", Amount: 5, Reason: " "},
|
||||
"reason too long": {Currency: "POINT", Amount: 5, Reason: strings.Repeat("a", 256)},
|
||||
"cash-out reason": {Currency: "POINT", Amount: -500, Reason: "Pencairan saldo ke rekening"},
|
||||
"cash-out, English": {Currency: "POINT", Amount: -500, Reason: "customer asked to cash out"},
|
||||
"long key": {Currency: "POINT", Amount: 5, Reason: "x", IdempotencyKey: strings.Repeat("k", 51)},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
err, code := v.ValidateAdjustRequest(req)
|
||||
assert.Error(t, err)
|
||||
assert.NotEmpty(t, code)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user