Skip to content

Commit

Permalink
[uptime] Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wafuwafu13 committed Sep 2, 2022
1 parent 2c2345f commit 1d89a1d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mackerel-plugin-uptime/lib/uptime_test.go
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))
}
}

0 comments on commit 1d89a1d

Please sign in to comment.