Skip to content

Commit

Permalink
OCM-7573 | fix: ensure version option args are initialised
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranRoche committed Apr 30, 2024
1 parent 51a6360 commit 92e0348
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/rosa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,21 @@ func versionCheck(cmd *cobra.Command, _ []string) {
rprtr := reporter.CreateReporter()
rosaVersion, err := versionUtils.NewRosaVersion()
if err != nil {
rprtr.Warnf("Could not verify the current version of ROSA.")
rprtr.Warnf("You might be running on an outdated version. Make sure you are using the current version of ROSA.")
rprtr.Debugf("Could not verify the current version of ROSA: %v", err)
rprtr.Debugf("You might be running on an outdated version. Make sure you are using the current version of ROSA.")
return
}
latestVersionFromMirror, isLatest, err := rosaVersion.IsLatest(info.Version)
if err != nil {
rprtr.Warnf("There was a problem retrieving the latest version of ROSA.")
rprtr.Warnf("You might be running on an outdated version. Make sure you are using the current version of ROSA.")
rprtr.Debugf("There was a problem retrieving the latest version of ROSA: %v", err)
rprtr.Debugf("You might be running on an outdated version. Make sure you are using the current version of ROSA.")
return
}
if !isLatest {
rprtr.Warnf("The current version (%s) is not up to date with latest released version (%s).",
info.Version,
latestVersionFromMirror.Original(),
)

rprtr.Warnf("It is recommended that you update to the latest version.")
}
}
30 changes: 30 additions & 0 deletions cmd/version/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,36 @@ var _ = Describe("RosaVersionOptions", func() {
mockVerify *rosa.MockVerifyRosa
)

Context("NewRosaVersionOptions", func() {
var (
options *RosaVersionOptions
err error
)

BeforeEach(func() {
options, err = NewRosaVersionOptions()
})

It("should not return an error", func() {
Expect(err).ToNot(HaveOccurred())
})

It("should initialize reporter", func() {
Expect(options).ToNot(BeNil())
Expect(options.reporter).ToNot(BeNil())
})

It("should initialize verifyRosa", func() {
Expect(options).ToNot(BeNil())
Expect(options.verifyRosa).ToNot(BeNil())
})

It("should initialize args", func() {
Expect(options).ToNot(BeNil())
Expect(options.args).ToNot(BeNil())
})
})

When("When client only is set to false", func() {
BeforeEach(func() {
ctrl = gomock.NewController(GinkgoT())
Expand Down
1 change: 1 addition & 0 deletions cmd/version/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func NewRosaVersionOptions() (*RosaVersionOptions, error) {
return &RosaVersionOptions{
verifyRosa: verifyRosa,
reporter: reporter.CreateReporter(),
args: NewRosaVersionUserOptions(),
}, nil
}

Expand Down

0 comments on commit 92e0348

Please sign in to comment.