-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2feecff
commit 163bc7d
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package pwrstat | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConstruct(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
sample := ` | ||
The UPS information shows as following: | ||
Properties: | ||
Model Name................... CP1000PFCLCDa | ||
Firmware Number.............. CR01803BBI11 | ||
Rating Voltage............... 120 V | ||
Rating Power................. 600 Watt(1000 VA) | ||
Current UPS status: | ||
State........................ Normal | ||
Power Supply by.............. Utility Power | ||
Utility Voltage.............. 114 V | ||
Output Voltage............... 114 V | ||
Battery Capacity............. 100 % | ||
Remaining Runtime............ 35 min. | ||
Load......................... 114 Watt(19 %) | ||
Line Interaction............. None | ||
Test Result.................. Passed at 2022/09/21 20:44:29 | ||
Last Power Event............. None | ||
` | ||
|
||
actual := parseOutput(sample) // Make sure Construct is exported in pwrstat.go | ||
assert.Len(actual.Status, 14, "Status should contain 14 entries") | ||
|
||
actualBatteryCapacity, ok := actual.Status["Battery Capacity"] | ||
assert.True(ok, "Battery Capacity key should exist") | ||
assert.Equal("100 %", actualBatteryCapacity, "Battery Capacity should be 100 %") | ||
} |