File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
src/go/apps/auction-item-stat-scraper/converter Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ package converter
2+
3+ import (
4+ "testing"
5+
6+ "github.com/KubrickCode/loa-work/src/go/libs/loadb"
7+ "github.com/shopspring/decimal"
8+ )
9+
10+ func TestCalculateAveragePrice (t * testing.T ) {
11+ tests := []struct {
12+ name string
13+ stats []loadb.AuctionItemStat
14+ expected decimal.Decimal
15+ }{
16+ {
17+ name : "정상적인 가격" ,
18+ stats : []loadb.AuctionItemStat {
19+ {BuyPrice : 100 },
20+ {BuyPrice : 200 },
21+ {BuyPrice : 300 },
22+ },
23+ expected : decimal .NewFromInt (200 ),
24+ },
25+ {
26+ name : "빈 배열" ,
27+ stats : []loadb.AuctionItemStat {},
28+ expected : decimal .NewFromInt (0 ),
29+ },
30+ {
31+ name : "하나의 가격" ,
32+ stats : []loadb.AuctionItemStat {
33+ {BuyPrice : 150 },
34+ },
35+ expected : decimal .NewFromInt (150 ),
36+ },
37+ }
38+
39+ for _ , tt := range tests {
40+ t .Run (tt .name , func (t * testing.T ) {
41+ result := calculateAveragePrice (tt .stats )
42+ if ! result .Equal (tt .expected ) {
43+ t .Errorf ("expected %s, got %s" , tt .expected .String (), result .String ())
44+ }
45+ })
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments