@@ -3,7 +3,6 @@ package _tests_test
33import (
44 "bytes"
55 "fmt"
6- "io"
76 "math/rand"
87 "os"
98 "os/exec"
@@ -68,11 +67,16 @@ var _ = BeforeSuite(func() {
6867})
6968
7069var _ = AfterSuite (func () {
71- // cancel the test user
72- cancel (url , testUser , testPassword )
73-
74- // cancel the test-admin user
75- cancel (url , testAdminUser , testAdminPassword )
70+ cancelUserSess , cancelUserErr := cancelSess (url , testUser , testPassword )
71+ cancelAdminSess , cancelAdminErr := cancelSess (url , testAdminUser , testAdminPassword )
72+ Expect (cancelUserErr ).To (BeNil ())
73+ Expect (cancelAdminErr ).To (BeNil ())
74+ cancelUserSess .Wait ()
75+ cancelAdminSess .Wait ()
76+ Expect (cancelUserSess .ExitCode ()).To (BeZero ())
77+ Expect (cancelAdminSess .ExitCode ()).To (BeZero ())
78+ Expect (cancelUserSess .Out .Contents ()).To (ContainSubstring ("Account cancelled" ))
79+ Expect (cancelAdminSess .Out .Contents ()).To (ContainSubstring ("Account cancelled" ))
7680})
7781
7882func register (url , username , password , email string ) {
@@ -82,6 +86,16 @@ func register(url, username, password, email string) {
8286 Eventually (sess ).Should (gbytes .Say ("Logged in as %s" , username ))
8387}
8488
89+ func cancelSess (url , user , pass string ) (* gexec.Session , error ) {
90+ lgSess , err := loginSess (url , user , pass )
91+ if err != nil {
92+ return nil , err
93+ }
94+ lgSess .Wait ()
95+ cmd := exec .Command ("deis" , "auth:cancel" , fmt .Sprintf ("--username=%s" , user ), fmt .Sprintf ("--password=%s" , pass ), "--yes" )
96+ return gexec .Start (cmd , GinkgoWriter , GinkgoWriter )
97+ }
98+
8599func cancel (url , username , password string ) {
86100 // log in to the account
87101 login (url , username , password )
@@ -93,6 +107,11 @@ func cancel(url, username, password string) {
93107 Eventually (sess ).Should (gbytes .Say ("Account cancelled" ))
94108}
95109
110+ func loginSess (url , user , pass string ) (* gexec.Session , error ) {
111+ cmd := exec .Command ("deis" , "login" , url , fmt .Sprintf ("--username=%s" , user ), fmt .Sprintf ("--password=%s" , pass ))
112+ return gexec .Start (cmd , GinkgoWriter , GinkgoWriter )
113+ }
114+
96115func login (url , user , password string ) {
97116 sess , err := start ("deis login %s --username=%s --password=%s" , url , user , password )
98117 Expect (err ).To (BeNil ())
0 commit comments