Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #929 from wafuwafu13/uptime-test
[uptime] Add tests
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package mpuptime | ||
|
||
import "testing" | ||
|
||
func TestFetchMetrics(t *testing.T) { | ||
var uptime UptimePlugin | ||
|
||
stat, err := uptime.FetchMetrics() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
seconds := stat["seconds"] | ||
if seconds <= 0 { | ||
t.Errorf("invalid seconds value: %f", seconds) | ||
} | ||
} | ||
|
||
func TestGraphDefinition(t *testing.T) { | ||
var uptime UptimePlugin | ||
|
||
graphdef := uptime.GraphDefinition() | ||
if len(graphdef) != 1 { | ||
t.Errorf("GetTempfilename: %d should be 1", len(graphdef)) | ||
} | ||
} |