Skip to content

Commit

Permalink
Merge pull request #929 from wafuwafu13/uptime-test
Browse files Browse the repository at this point in the history
[uptime] Add tests
  • Loading branch information
lufia committed Sep 7, 2022
2 parents 2c2345f + 1d89a1d commit 62cc9b9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mackerel-plugin-uptime/lib/uptime_test.go
@@ -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 62cc9b9

Please sign in to comment.