Skip to content

Commit

Permalink
Merge pull request #25 from ebc-2in2crc/issue/24/support-pixela-v1.27.0
Browse files Browse the repository at this point in the history
Support Pixela v1.27.0
  • Loading branch information
ebc-2in2crc authored Sep 5, 2023
2 parents 92452d5 + 9c57db0 commit 6ce8fdf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
15 changes: 9 additions & 6 deletions graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,15 @@ type GraphURLInput struct {

// Stats is various statistics based on the registered information.
type Stats struct {
TotalPixelsCount int `json:"totalPixelsCount"`
MaxQuantity int `json:"maxQuantity"`
MinQuantity int `json:"minQuantity"`
TotalQuantity int `json:"totalQuantity"`
AvgQuantity float64 `json:"avgQuantity"`
TodaysQuantity int `json:"todaysQuantity"`
TotalPixelsCount int `json:"totalPixelsCount"`
MaxQuantity int `json:"maxQuantity"`
MaxDate string `json:"maxDate"`
MinQuantity int `json:"minQuantity"`
MinDate string `json:"minDate"`
TotalQuantity int `json:"totalQuantity"`
AvgQuantity float64 `json:"avgQuantity"`
TodaysQuantity int `json:"todaysQuantity"`
YesterdayQuantity int `json:"yesterdayQuantity"`
Result
}

Expand Down
19 changes: 11 additions & 8 deletions graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func TestGraph_CreateStatsRequestParameter(t *testing.T) {
}

func TestGraph_Stats(t *testing.T) {
s := `{"totalPixelsCount":1,"maxQuantity":2,"minQuantity":3,"totalQuantity":4,"avgQuantity":5.0,"todaysQuantity":6}`
s := `{"totalPixelsCount":1,"maxQuantity":2,"maxDate":"2023-09-01","minQuantity":3,"minDate":"2023-09-02","totalQuantity":4,"avgQuantity":5.0,"todaysQuantity":6,"yesterdayQuantity":66}`
b := []byte(s)
clientMock = &httpClientMock{statusCode: http.StatusOK, body: b}

Expand All @@ -315,13 +315,16 @@ func TestGraph_Stats(t *testing.T) {
}

expect := &Stats{
TotalPixelsCount: 1,
MaxQuantity: 2,
MinQuantity: 3,
TotalQuantity: 4,
AvgQuantity: 5.0,
TodaysQuantity: 6,
Result: Result{IsSuccess: true, StatusCode: http.StatusOK},
TotalPixelsCount: 1,
MaxQuantity: 2,
MaxDate: "2023-09-01",
MinQuantity: 3,
MinDate: "2023-09-02",
TotalQuantity: 4,
AvgQuantity: 5.0,
TodaysQuantity: 6,
YesterdayQuantity: 66,
Result: Result{IsSuccess: true, StatusCode: http.StatusOK},
}
if *stats != *expect {
t.Errorf("got: %v\nwant: %v", stats, expect)
Expand Down

0 comments on commit 6ce8fdf

Please sign in to comment.