commit 2025f2329cc1398382cfbd0faf60fd629a3c0d57
parent 524d07dfa0c251fdada838a2e574e30bbabf5dad
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 15 Dec 2023 22:55:21 -0500
fix tests
Diffstat:
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/pkg/web/handlers/poker/poker_test.go b/pkg/web/handlers/poker/poker_test.go
@@ -1,6 +1,7 @@
package poker
import (
+ "dkforest/pkg/database"
"github.com/stretchr/testify/assert"
"testing"
)
@@ -33,11 +34,11 @@ func Test_processPot(t *testing.T) {
{1, []*PokerPlayer{p2, p4, p1, p3}},
}
sortGameResults(arr)
- res, _ = processPot(arr, 1000, 20, true)
- assert.Equal(t, 250, res[0].Gain)
- assert.Equal(t, 250, res[1].Gain)
- assert.Equal(t, 250, res[2].Gain)
- assert.Equal(t, 250, res[3].Gain)
+ res, _ = processPot(arr, 1000, 20, false)
+ assert.Equal(t, database.PokerChip(250), res[0].Gain)
+ assert.Equal(t, database.PokerChip(250), res[1].Gain)
+ assert.Equal(t, database.PokerChip(250), res[2].Gain)
+ assert.Equal(t, database.PokerChip(250), res[3].Gain)
p1 = &PokerPlayer{SeatedPlayer: &SeatedPlayer{Cash: 0, Username: "p1"}, RoundTotalBet: 10, AllInMaxGain: 40}
p2 = &PokerPlayer{SeatedPlayer: &SeatedPlayer{Cash: 0, Username: "p2"}, RoundTotalBet: 20, AllInMaxGain: 70}
@@ -47,11 +48,11 @@ func Test_processPot(t *testing.T) {
{1, []*PokerPlayer{p2, p4, p1, p3}},
}
sortGameResults(arr)
- res, _ = processPot(arr, 1000, 20, true)
- assert.Equal(t, 40, res[0].Gain)
- assert.Equal(t, 70, res[1].Gain)
- assert.Equal(t, 445, res[2].Gain)
- assert.Equal(t, 445, res[3].Gain)
+ res, _ = processPot(arr, 1000, 20, false)
+ assert.Equal(t, database.PokerChip(40), res[0].Gain)
+ assert.Equal(t, database.PokerChip(70), res[1].Gain)
+ assert.Equal(t, database.PokerChip(445), res[2].Gain)
+ assert.Equal(t, database.PokerChip(445), res[3].Gain)
p1 = &PokerPlayer{SeatedPlayer: &SeatedPlayer{Cash: 1, Username: "p1"}, RoundTotalBet: 500}
p2 = &PokerPlayer{SeatedPlayer: &SeatedPlayer{Cash: 0, Username: "p2"}, RoundTotalBet: 500, AllInMaxGain: 1000}
@@ -60,10 +61,10 @@ func Test_processPot(t *testing.T) {
{2, []*PokerPlayer{p1}},
}
sortGameResults(arr)
- res, _ = processPot(arr, 1000, 20, true)
+ res, _ = processPot(arr, 1000, 20, false)
assert.Equal(t, 1, len(res))
- assert.Equal(t, "p2", res[0].Player.Username)
- assert.Equal(t, 1000, res[0].Gain)
+ assert.Equal(t, database.Username("p2"), res[0].Player.Username)
+ assert.Equal(t, database.PokerChip(1000), res[0].Gain)
p1 = &PokerPlayer{SeatedPlayer: &SeatedPlayer{Cash: 1, Username: "p1"}, RoundTotalBet: 5}
p2 = &PokerPlayer{SeatedPlayer: &SeatedPlayer{Cash: 1, Username: "p2"}, RoundTotalBet: 5}
@@ -75,11 +76,11 @@ func Test_processPot(t *testing.T) {
{2, []*PokerPlayer{p4}},
}
sortGameResults(arr)
- res, _ = processPot(arr, 23, 20, true)
+ res, _ = processPot(arr, 23, 20, false)
assert.Equal(t, 3, len(res))
- assert.Equal(t, 8, res[0].Gain)
- assert.Equal(t, 8, res[1].Gain)
- assert.Equal(t, 7, res[2].Gain)
+ assert.Equal(t, database.PokerChip(8), res[0].Gain)
+ assert.Equal(t, database.PokerChip(8), res[1].Gain)
+ assert.Equal(t, database.PokerChip(7), res[2].Gain)
p1 = &PokerPlayer{SeatedPlayer: &SeatedPlayer{Cash: 0, Username: "p1"}, RoundTotalBet: 900, AllInMaxGain: 1560}
p2 = &PokerPlayer{SeatedPlayer: &SeatedPlayer{Cash: 0, Username: "p2"}, RoundTotalBet: 640, AllInMaxGain: 1300}
@@ -88,10 +89,10 @@ func Test_processPot(t *testing.T) {
{2, []*PokerPlayer{p1}},
}
sortGameResults(arr)
- res, _ = processPot(arr, 1560, 20, true)
+ res, _ = processPot(arr, 1560, 20, false)
assert.Equal(t, 2, len(res))
- assert.Equal(t, 1300, res[0].Gain)
- assert.Equal(t, 260, res[1].Gain)
+ assert.Equal(t, database.PokerChip(1300), res[0].Gain)
+ assert.Equal(t, database.PokerChip(260), res[1].Gain)
}
func Test_isRoundSettled(t *testing.T) {