-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glrdomon_test.go
50 lines (39 loc) · 919 Bytes
/
glrdomon_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"testing"
"time"
"github.com/digitalocean/godo"
)
func TestCheckDropletAge(t *testing.T) {
threshold = 3600
setUpLogger("os.Stdout")
staleDroplet := godo.Droplet{
ID: 1234,
Name: "very-old",
Created: "2000-08-19T19:07:04Z",
}
if !checkDropletAge(staleDroplet) {
t.Error("Failed to assert that very old droplet is stale")
}
now := time.Now()
newDroplet := godo.Droplet{
ID: 5678,
Name: "new",
Created: now.Format(time.RFC3339),
}
if checkDropletAge(newDroplet) {
t.Error("Asserted that brand-new droplet is stale")
}
}
func TestValidatePath(t *testing.T) {
emptyString := ""
notValid := validatePath(&emptyString)
if notValid == true {
t.Error("Empty path shouldn't validate")
}
sampleConfig := "./config-sample.json"
valid := validatePath(&sampleConfig)
if valid != true {
t.Error("Couldn't validate path to sample config")
}
}