Skip to content

Commit

Permalink
Add test for bug #216
Browse files Browse the repository at this point in the history
  • Loading branch information
petersutter committed Jan 24, 2023
1 parent 94610fc commit 0174187
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
package cmd_test

import (
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -80,4 +81,35 @@ var _ = Describe("Gardenctl command", func() {
})
})
})

Context("when running the help command", func() {
var (
sessionID string
termSessionID string
)

BeforeEach(func() {
sessionID = os.Getenv("GCTL_SESSION_ID")
termSessionID = os.Getenv("GCTL_SESSION_ID")

Expect(os.Unsetenv("GCTL_SESSION_ID")).To(Succeed())
Expect(os.Unsetenv("TERM_SESSION_ID")).To(Succeed())
})

AfterEach(func() {
// restore env variables
Expect(os.Setenv("GCTL_SESSION_ID", sessionID)).To(Succeed())
Expect(os.Setenv("TERM_SESSION_ID", termSessionID)).To(Succeed())
})

It("should succeed without session IDs", func() {
args := []string{
"help",
}

cmd := cmd.NewGardenctlCommand(util.NewFactoryImpl(), streams)
cmd.SetArgs(args)
Expect(cmd.Execute()).To(Succeed())
})
})
})

0 comments on commit 0174187

Please sign in to comment.