-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathps_test.go
More file actions
63 lines (55 loc) · 1.83 KB
/
ps_test.go
File metadata and controls
63 lines (55 loc) · 1.83 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 (
"github.com/deis/workflow-cli/settings"
"io/ioutil"
"os"
"testing"
)
func TestScaleFail(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "tmpdir")
if err != nil {
t.Fatalf("error creating temp directory (%s)", err)
}
err = os.Mkdir(tmpDir+"/.deis", 0666)
if err != nil {
t.Fatalf("error creating temp directory (%s)", err)
}
os.Setenv("DEIS_PROFILE", "testing")
settings.SetHome(tmpDir)
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(tmpDir+"/.deis/testing.json", data, 0644); err != nil {
t.Fatalf("error creating %s/.deis/testing.json (%s)", tmpDir, err)
}
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"
actual := 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")
}
}