47 lines
1.7 KiB
Go
47 lines
1.7 KiB
Go
package registerreward
|
|
|
|
import "testing"
|
|
|
|
func TestDeriveRegisterRewardClaimResult(t *testing.T) {
|
|
t.Run("rewarded success", func(t *testing.T) {
|
|
got := deriveRegisterRewardClaimResult(registerRewardStatusSuccess, registerRewardGrantModeIssueReward)
|
|
if got != registerRewardClaimResultRewarded {
|
|
t.Fatalf("deriveRegisterRewardClaimResult() = %s, want %s", got, registerRewardClaimResultRewarded)
|
|
}
|
|
})
|
|
|
|
t.Run("quota exhausted success", func(t *testing.T) {
|
|
got := deriveRegisterRewardClaimResult(registerRewardStatusSuccess, registerRewardGrantModeQuotaExhausted)
|
|
if got != registerRewardClaimResultQuotaExhausted {
|
|
t.Fatalf("deriveRegisterRewardClaimResult() = %s, want %s", got, registerRewardClaimResultQuotaExhausted)
|
|
}
|
|
})
|
|
|
|
t.Run("failed issue reward", func(t *testing.T) {
|
|
got := deriveRegisterRewardClaimResult(registerRewardStatusFailed, registerRewardGrantModeIssueReward)
|
|
if got != registerRewardClaimResultFailed {
|
|
t.Fatalf("deriveRegisterRewardClaimResult() = %s, want %s", got, registerRewardClaimResultFailed)
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestResolveRegisterRewardRemainingCount(t *testing.T) {
|
|
t.Run("unlimited returns zero", func(t *testing.T) {
|
|
if got := resolveRegisterRewardRemainingCount(0, 12); got != 0 {
|
|
t.Fatalf("resolveRegisterRewardRemainingCount() = %d, want 0", got)
|
|
}
|
|
})
|
|
|
|
t.Run("remaining cannot be negative", func(t *testing.T) {
|
|
if got := resolveRegisterRewardRemainingCount(5, 9); got != 0 {
|
|
t.Fatalf("resolveRegisterRewardRemainingCount() = %d, want 0", got)
|
|
}
|
|
})
|
|
|
|
t.Run("remaining uses occupied count", func(t *testing.T) {
|
|
if got := resolveRegisterRewardRemainingCount(20, 7); got != 13 {
|
|
t.Fatalf("resolveRegisterRewardRemainingCount() = %d, want 13", got)
|
|
}
|
|
})
|
|
}
|