11package cmd
22
3- import "testing"
3+ import (
4+ "github.com/deis/workflow-cli/settings"
5+ "io/ioutil"
6+ "os"
7+ "testing"
8+ )
9+
10+ func TestScaleFail (t * testing.T ) {
11+ tmpDir , err := ioutil .TempDir ("" , "tmpdir" )
12+ if err != nil {
13+ t .Fatalf ("error creating temp directory (%s)" , err )
14+ }
15+ err = os .Mkdir (tmpDir + "/.deis" , 0666 )
16+ if err != nil {
17+ t .Fatalf ("error creating temp directory (%s)" , err )
18+ }
19+ os .Setenv ("DEIS_PROFILE" , "testing" )
20+ settings .SetHome (tmpDir )
21+ data := []byte (`{"username":"test","ssl_verify":false,"controller":"http://deis.127.0.0.1.nip.io","token":"test","response_limit":0}` )
22+ if err := ioutil .WriteFile (tmpDir + "/.deis/testing.json" , data , 0644 ); err != nil {
23+ t .Fatalf ("error creating %s/.deis/testing.json (%s)" , tmpDir , err )
24+ }
25+ defer func () {
26+ if err := os .RemoveAll (tmpDir ); err != nil {
27+ t .Fatalf ("failed to remove creds file from %s (%s)" , tmpDir , err )
28+ }
29+ }()
30+
31+ expected := "'web=-1' does not match the pattern 'type=num', ex: web=2\n "
32+ actual := PsScale ("testApp" , []string {"web=-1" })
33+ if actual .Error () != expected {
34+ t .Errorf ("Expected %s, Got %s" , expected , actual )
35+ }
36+ }
437
538func TestParseType (t * testing.T ) {
639 t .Parallel ()
@@ -21,7 +54,6 @@ func TestParseType(t *testing.T) {
2154 t .Errorf ("type was not cmd (got %s) or psName was not %s (got %s)" , psType , deployPod , psName )
2255 }
2356
24-
2557 // test type by itself
2658 psType , psName = parseType ("cmd" , "fake" )
2759 if psType != "cmd" || psName != "" {
0 commit comments