Skip to content

Commit

Permalink
Merge pull request #10 from atbore-phx/feat/test-errors
Browse files Browse the repository at this point in the history
feat(tests): improved storage tests
  • Loading branch information
atbore-phx authored Mar 5, 2024
2 parents 65d13e8 + b69e836 commit 2e9362f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pkg/storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ var resp string = `{
}
}`

var respBD string = `{
"Body" : {
"Data" : {
"0" : {
"Controller" : {
"DesignedCapacity" : 11059.0,
"Enable" : 0,
"StateOfCharge_Relative" : 82.0
}
},
"1" : {
"Controller" : {
"DesignedCapacity" : 13809.0,
"Enable" : 0,
"StateOfCharge_Relative" : 70.0
}
}
}
}
}`

var respJsonErr string = `{
"Body" : {
"Data" : {
Expand Down Expand Up @@ -207,3 +228,17 @@ func TestHandlerError2(t *testing.T) {

teardown()
}

func TestHandlerError3(t *testing.T) {
setup(respBD)

st := storage.New()
ip := strings.TrimPrefix(mockServer.URL, "http://")

charge, charge_max, err := st.Handler(ip)
assert.Equal(t, float64(0), charge)
assert.Equal(t, float64(0), charge_max)
assert.Error(t, err)

teardown()
}

0 comments on commit 2e9362f

Please sign in to comment.