/
heroku_test.go
53 lines (46 loc) · 1.06 KB
/
heroku_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
51
52
53
// Copyright (c) 2013 Jason McVetta. This is Free Software, released under the
// terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details.
// Resist intellectual serfdom - the ownership of ideas is akin to slavery.
package heroku
import (
"github.com/darkhelmet/env"
"github.com/jmcvetta/randutil"
"log"
"net/http"
"strings"
"testing"
)
func setup(t *testing.T) *Heroku {
log.SetFlags(log.Lshortfile)
key := env.String("HEROKU_TEST_API_KEY")
h := NewHeroku(key)
h.rc.Log = false
return h
}
func BadResponder(w http.ResponseWriter, r *http.Request) {
http.Error(w, "", 999)
}
func appName(t *testing.T) string {
rnd, err := randutil.AlphaString(25)
if err != nil {
t.Fatal(err)
}
rnd = strings.ToLower(rnd)
return "test-" + rnd
}
func cleanup(t *testing.T, h *Heroku) {
m, err := h.Apps()
if err != nil {
t.Fatal(err)
}
for name := range m {
err = h.DestroyApp(name)
if err != nil {
t.Fatal(err)
}
}
}
func TestPrettyPrint(t *testing.T) {
// This test can only fail with a panic
prettyPrint(map[string]string{"foo": "bar"})
}