@@ -13,6 +13,12 @@ import (
1313)
1414
1515var _ = Describe ("when testing tail-logs subcommand" , func () {
16+ var tearDowns []machine.TearDownFunc
17+
18+ AfterEach (func () {
19+ Expect (env .TearDownAll (tearDowns )).To (Succeed ())
20+ })
21+
1622 Context ("subcommand must be working" , func () {
1723 podName := "test-pod-bar-foo"
1824 parentCName := "fake-nats"
@@ -29,7 +35,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {
2935
3036 tearDown , err := env .CreatePod (env .Namespace , testPod )
3137 Expect (err ).NotTo (HaveOccurred ())
32- defer func ( tdf machine. TearDownFunc ) { Expect ( tdf ()). To ( Succeed ()) }( tearDown )
38+ tearDowns = append ( tearDowns , tearDown )
3339
3440 err = env .WaitForPod (env .Namespace , podName )
3541 Expect (err ).NotTo (HaveOccurred ())
@@ -55,7 +61,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {
5561
5662 tearDown , err := env .CreatePod (env .Namespace , testPod )
5763 Expect (err ).NotTo (HaveOccurred ())
58- defer func ( tdf machine. TearDownFunc ) { Expect ( tdf ()). To ( Succeed ()) }( tearDown )
64+ tearDowns = append ( tearDowns , tearDown )
5965
6066 err = env .WaitForPod (env .Namespace , podName )
6167 Expect (err ).NotTo (HaveOccurred ())
@@ -80,7 +86,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {
8086
8187 tearDown , err := env .CreatePod (env .Namespace , testPod )
8288 Expect (err ).NotTo (HaveOccurred ())
83- defer func ( tdf machine. TearDownFunc ) { Expect ( tdf ()). To ( Succeed ()) }( tearDown )
89+ tearDowns = append ( tearDowns , tearDown )
8490
8591 err = env .WaitForPod (env .Namespace , podName )
8692 Expect (err ).NotTo (HaveOccurred ())
@@ -100,7 +106,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {
100106
101107 tearDown , err := env .CreatePod (env .Namespace , testPod )
102108 Expect (err ).NotTo (HaveOccurred ())
103- defer func ( tdf machine. TearDownFunc ) { Expect ( tdf ()). To ( Succeed ()) }( tearDown )
109+ tearDowns = append ( tearDowns , tearDown )
104110
105111 err = env .WaitForPod (env .Namespace , podName )
106112 Expect (err ).NotTo (HaveOccurred ())
@@ -120,7 +126,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {
120126
121127 tearDown , err := env .CreatePod (env .Namespace , testPod )
122128 Expect (err ).NotTo (HaveOccurred ())
123- defer func ( tdf machine. TearDownFunc ) { Expect ( tdf ()). To ( Succeed ()) }( tearDown )
129+ tearDowns = append ( tearDowns , tearDown )
124130
125131 err = env .WaitForPod (env .Namespace , podName )
126132 Expect (err ).NotTo (HaveOccurred ())
@@ -131,7 +137,6 @@ var _ = Describe("when testing tail-logs subcommand", func() {
131137 time .Sleep (1 * time .Minute )
132138 err = env .WaitForPodContainerLogMsg (env .Namespace , podName , sidecarCName , "running logrotate" )
133139 Expect (err ).NotTo (HaveOccurred ())
134-
135140 })
136141 })
137142})
0 commit comments