-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathps_test.go
More file actions
63 lines (52 loc) · 1.67 KB
/
ps_test.go
File metadata and controls
63 lines (52 loc) · 1.67 KB
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
54
55
56
57
58
59
60
61
62
63
package cmd
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestScaleFail(t *testing.T) {
t.Parallel()
tmpDir, err := ioutil.TempDir("", "tmpdir")
if err != nil {
t.Fatalf("error creating temp directory (%s)", err)
}
file := filepath.Join(tmpDir, "client.json")
data := []byte(`{"username":"test","ssl_verify":false,"controller":"http://deis.127.0.0.1.nip.io","token":"test","response_limit":0}`)
if err := ioutil.WriteFile(file, data, 0644); err != nil {
t.Fatal("error creating config file")
}
defer func() {
if err := os.RemoveAll(tmpDir); err != nil {
t.Fatalf("failed to remove creds file from %s (%s)", tmpDir, err)
}
}()
expected := "'web=-1' does not match the pattern 'type=num', ex: web=2\n"
d := DeisCmd{ConfigFile: file}
actual := d.PsScale("testApp", []string{"web=-1"})
if actual.Error() != expected {
t.Errorf("Expected %s, Got %s", expected, actual)
}
}
func TestParseType(t *testing.T) {
t.Parallel()
// test RC pod name
appID := "earthy-underdog"
rcPod := "earthy-underdog-v2-cmd-8yngj"
psType, psName := parseType(rcPod, appID)
if psType != "cmd" || psName != rcPod {
t.Errorf("type was not cmd (got %s) or psName was not %s (got %s)", psType, rcPod, psName)
}
// test Deployment pod name - they are longer due to hash
appID = "nonfat-yearbook"
deployPod := "nonfat-yearbook-cmd-2180299075-7na91"
psType, psName = parseType(deployPod, appID)
if psType != "cmd" || psName != deployPod {
t.Errorf("type was not cmd (got %s) or psName was not %s (got %s)", psType, deployPod, psName)
}
// test type by itself
psType, psName = parseType("cmd", "fake")
if psType != "cmd" || psName != "" {
t.Error("type was not cmd")
}
}