glrdomon_test.go 874 Bytes
Newer Older
Erick Hitter's avatar
Erick Hitter committed
1 2
package main

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
import (
	"testing"
	"time"

	"github.com/digitalocean/godo"
)

func TestCheckDropletAge(t *testing.T) {
	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")
	}
}
Erick Hitter's avatar
Erick Hitter committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

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")
	}
}