dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit ab7c91b5b4fd42902117a14f1c56900dcb20f5d6
parent 6671d600f223aac4f7a9db5c2bffcd3067ef8c39
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sat,  9 Dec 2023 06:15:49 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker/poker_test.go | 58+++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 35 insertions(+), 23 deletions(-)

diff --git a/pkg/web/handlers/poker/poker_test.go b/pkg/web/handlers/poker/poker_test.go @@ -6,10 +6,10 @@ import ( ) func Test_sortGameResults(t *testing.T) { - p1 := &PokerPlayer{Cash: 0, RoundTotalBet: 10, Username: "p1"} - p2 := &PokerPlayer{Cash: 0, RoundTotalBet: 20, Username: "p2"} - p3 := &PokerPlayer{Cash: 0, RoundTotalBet: 30, Username: "p3"} - p4 := &PokerPlayer{Cash: 1, RoundTotalBet: 100, Username: "p4"} + p1 := &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p1"}, RoundTotalBet: 10} + p2 := &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p2"}, RoundTotalBet: 20} + p3 := &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p3"}, RoundTotalBet: 30} + p4 := &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 1, Username: "p4"}, RoundTotalBet: 100} arr := []GameResult{ {1, []*PokerPlayer{p2, p4, p1, p3}}, } @@ -25,10 +25,10 @@ func Test_processPot(t *testing.T) { var arr []GameResult var res []PlayerGain - p1 = &PokerPlayer{Cash: 0, RoundTotalBet: 100, AllInMaxGain: 400, Username: "p1"} - p2 = &PokerPlayer{Cash: 0, RoundTotalBet: 200, AllInMaxGain: 700, Username: "p2"} - p3 = &PokerPlayer{Cash: 0, RoundTotalBet: 300, AllInMaxGain: 900, Username: "p3"} - p4 = &PokerPlayer{Cash: 1, RoundTotalBet: 400, Username: "p4"} + p1 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p1"}, RoundTotalBet: 100, AllInMaxGain: 400} + p2 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p2"}, RoundTotalBet: 200, AllInMaxGain: 700} + p3 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p3"}, RoundTotalBet: 300, AllInMaxGain: 900} + p4 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 1, Username: "p4"}, RoundTotalBet: 400} arr = []GameResult{ {1, []*PokerPlayer{p2, p4, p1, p3}}, } @@ -39,10 +39,10 @@ func Test_processPot(t *testing.T) { assert.Equal(t, 250, res[2].Gain) assert.Equal(t, 250, res[3].Gain) - p1 = &PokerPlayer{Cash: 0, RoundTotalBet: 10, AllInMaxGain: 40, Username: "p1"} - p2 = &PokerPlayer{Cash: 0, RoundTotalBet: 20, AllInMaxGain: 70, Username: "p2"} - p3 = &PokerPlayer{Cash: 0, RoundTotalBet: 300, AllInMaxGain: 630, Username: "p3"} - p4 = &PokerPlayer{Cash: 1, RoundTotalBet: 400, Username: "p4"} + p1 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p1"}, RoundTotalBet: 10, AllInMaxGain: 40} + p2 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p2"}, RoundTotalBet: 20, AllInMaxGain: 70} + p3 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p3"}, RoundTotalBet: 300, AllInMaxGain: 630} + p4 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 1, Username: "p4"}, RoundTotalBet: 400} arr = []GameResult{ {1, []*PokerPlayer{p2, p4, p1, p3}}, } @@ -53,8 +53,8 @@ func Test_processPot(t *testing.T) { assert.Equal(t, 445, res[2].Gain) assert.Equal(t, 445, res[3].Gain) - p1 = &PokerPlayer{Cash: 1, RoundTotalBet: 500, Username: "p1"} - p2 = &PokerPlayer{Cash: 0, RoundTotalBet: 500, AllInMaxGain: 1000, Username: "p2"} + p1 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 1, Username: "p1"}, RoundTotalBet: 500} + p2 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p2"}, RoundTotalBet: 500, AllInMaxGain: 1000} arr = []GameResult{ {1, []*PokerPlayer{p2}}, {2, []*PokerPlayer{p1}}, @@ -65,10 +65,10 @@ func Test_processPot(t *testing.T) { assert.Equal(t, "p2", res[0].Player.Username) assert.Equal(t, 1000, res[0].Gain) - p1 = &PokerPlayer{Cash: 1, RoundTotalBet: 5, Username: "p1"} - p2 = &PokerPlayer{Cash: 1, RoundTotalBet: 5, Username: "p2"} - p3 = &PokerPlayer{Cash: 1, RoundTotalBet: 5, Username: "p3"} - p4 = &PokerPlayer{Cash: 1, RoundTotalBet: 5, Username: "p4"} + p1 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 1, Username: "p1"}, RoundTotalBet: 5} + p2 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 1, Username: "p2"}, RoundTotalBet: 5} + p3 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 1, Username: "p3"}, RoundTotalBet: 5} + p4 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 1, Username: "p4"}, RoundTotalBet: 5} //p5 = &PokerPlayer{Cash: 1, RoundTotalBet: 3, Folded: true, Username: "p5"} arr = []GameResult{ {1, []*PokerPlayer{p1, p2, p3}}, @@ -81,8 +81,8 @@ func Test_processPot(t *testing.T) { assert.Equal(t, 8, res[1].Gain) assert.Equal(t, 7, res[2].Gain) - p1 = &PokerPlayer{Cash: 0, RoundTotalBet: 900, AllInMaxGain: 1560, Username: "p1"} - p2 = &PokerPlayer{Cash: 0, RoundTotalBet: 640, AllInMaxGain: 1300, Username: "p2"} + p1 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p1"}, RoundTotalBet: 900, AllInMaxGain: 1560} + p2 = &PokerPlayer{PokerStandingPlayer: &PokerStandingPlayer{Cash: 0, Username: "p2"}, RoundTotalBet: 640, AllInMaxGain: 1300} arr = []GameResult{ {1, []*PokerPlayer{p2}}, {2, []*PokerPlayer{p1}}, @@ -103,9 +103,21 @@ func Test_isRoundSettled(t *testing.T) { args args want bool }{ - {"1", args{players: []*PokerPlayer{{Bet: 10, Cash: 0}, {Bet: 20, Cash: 0}, {Bet: 30, Cash: 1}, {Bet: 30, Cash: 1}}}, true}, - {"2", args{players: []*PokerPlayer{{Bet: 100, Cash: 0}, {Bet: 20, Cash: 0}, {Bet: 30, Cash: 1}, {Bet: 30, Cash: 1}}}, false}, - {"3", args{players: []*PokerPlayer{{Bet: 10, Cash: 0}, {Bet: 200, Cash: 0}, {Bet: 30, Cash: 1}, {Bet: 30, Cash: 1}}}, false}, + {"1", args{players: []*PokerPlayer{ + {Bet: 10, PokerStandingPlayer: &PokerStandingPlayer{Cash: 0}}, + {Bet: 20, PokerStandingPlayer: &PokerStandingPlayer{Cash: 0}}, + {Bet: 30, PokerStandingPlayer: &PokerStandingPlayer{Cash: 1}}, + {Bet: 30, PokerStandingPlayer: &PokerStandingPlayer{Cash: 1}}}}, true}, + {"2", args{players: []*PokerPlayer{ + {Bet: 100, PokerStandingPlayer: &PokerStandingPlayer{Cash: 0}}, + {Bet: 20, PokerStandingPlayer: &PokerStandingPlayer{Cash: 0}}, + {Bet: 30, PokerStandingPlayer: &PokerStandingPlayer{Cash: 1}}, + {Bet: 30, PokerStandingPlayer: &PokerStandingPlayer{Cash: 1}}}}, false}, + {"3", args{players: []*PokerPlayer{ + {Bet: 10, PokerStandingPlayer: &PokerStandingPlayer{Cash: 0}}, + {Bet: 200, PokerStandingPlayer: &PokerStandingPlayer{Cash: 0}}, + {Bet: 30, PokerStandingPlayer: &PokerStandingPlayer{Cash: 1}}, + {Bet: 30, PokerStandingPlayer: &PokerStandingPlayer{Cash: 1}}}}, false}, // TODO: Add test cases. } for _, tt := range tests {