@@ -68,11 +68,16 @@ var _ = BeforeSuite(func() {
6868})
6969
7070var _ = AfterSuite (func () {
71- // cancel the test user
72- cancel (url , testUser , testPassword )
73-
74- // cancel the test-admin user
75- cancel (url , testAdminUser , testAdminPassword )
71+ cancelUserSess , cancelUserErr := cancelSess (url , testUser , testPassword )
72+ cancelAdminSess , cancelAdminErr := cancelSess (url , testAdminEmail , testAdminPassword )
73+ Expect (cancelUserErr ).To (BeNil ())
74+ Expect (cancelAdminErr ).To (BeNil ())
75+ cancelUserSess .Wait ()
76+ cancelAdminSess .Wait ()
77+ Expect (cancelUserSess .ExitCode ()).To (BeZero ())
78+ Expect (cancelAdminSess .ExitCode ()).To (BeZero ())
79+ Expect (cancelUserSess .Out .Contents ()).To (ContainSubstring ("Account cancelled" ))
80+ Expect (cancelAdminSess .Out .Contents ()).To (ContainSubstring ("Account cancelled" ))
7681})
7782
7883func register (url , username , password , email string ) {
@@ -82,6 +87,16 @@ func register(url, username, password, email string) {
8287 Eventually (sess ).Should (gbytes .Say ("Logged in as %s" , username ))
8388}
8489
90+ func cancelSess (url , user , pass string ) (* gexec.Session , error ) {
91+ lgSess , err := loginSess (url , user , pass )
92+ if err != nil {
93+ return nil , err
94+ }
95+ lgSess .Wait ()
96+ cmd := exec .Command ("deis" , "auth:cancel" , fmt .Sprintf ("--username=%s" , user ), fmt .Sprintf ("--password=%s" , pass ), "--yes" )
97+ return gexec .Start (cmd , GinkgoWriter , GinkgoWriter )
98+ }
99+
85100func cancel (url , username , password string ) {
86101 // log in to the account
87102 login (url , username , password )
@@ -93,6 +108,11 @@ func cancel(url, username, password string) {
93108 Eventually (sess ).Should (gbytes .Say ("Account cancelled" ))
94109}
95110
111+ func loginSess (url , user , pass string ) (* gexec.Session , error ) {
112+ cmd := exec .Command ("deis" , "login" , url , fmt .Sprintf ("--username=%s" , user ), fmt .Sprintf ("--password=%s" , pass ))
113+ return gexec .Start (cmd , GinkgoWriter , GinkgoWriter )
114+ }
115+
96116func login (url , user , password string ) {
97117 sess , err := start ("deis login %s --username=%s --password=%s" , url , user , password )
98118 Expect (err ).To (BeNil ())
0 commit comments