From 9850f4a450fe5a0ce37ab18189987b88d05dce00 Mon Sep 17 00:00:00 2001 From: "pavel.larkin" Date: Mon, 12 Feb 2024 12:11:54 -0800 Subject: [PATCH] Fix Apply and test.Suit Signed-off-by: pavel.larkin --- pkg/kopia/cli/internal/flag/flag.go | 2 +- pkg/kopia/cli/internal/test/flag_suite.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/kopia/cli/internal/flag/flag.go b/pkg/kopia/cli/internal/flag/flag.go index 66148034a1..39a357be53 100644 --- a/pkg/kopia/cli/internal/flag/flag.go +++ b/pkg/kopia/cli/internal/flag/flag.go @@ -36,7 +36,7 @@ func Apply(cli safecli.CommandAppender, flags ...Applier) error { if flag == nil { // if the flag is nil, skip it continue } - if err := flag.Apply(cli); err != nil { + if err := flag.Apply(sub); err != nil { return err } } diff --git a/pkg/kopia/cli/internal/test/flag_suite.go b/pkg/kopia/cli/internal/test/flag_suite.go index 7c41a1ea3a..7fe60d909c 100644 --- a/pkg/kopia/cli/internal/test/flag_suite.go +++ b/pkg/kopia/cli/internal/test/flag_suite.go @@ -62,7 +62,9 @@ func (t *FlagTest) assertNoError(c *check.C, err error) { // assertCLI asserts the builder's CLI output against ExpectedCLI. func (t *FlagTest) assertCLI(c *check.C, b *safecli.Builder) { - c.Check(b.Build(), check.DeepEquals, t.ExpectedCLI, t) + if t.ExpectedCLI != nil { + c.Check(b.Build(), check.DeepEquals, t.ExpectedCLI, t) + } } // assertLog asserts the builder's log output against ExpectedLog. @@ -74,11 +76,11 @@ func (t *FlagTest) assertLog(c *check.C, b *safecli.Builder) { // Test runs the flag test. func (ft *FlagTest) Test(c *check.C, b *safecli.Builder) { err := flag.Apply(b, ft.Flag) + ft.assertCLI(c, b) if ft.ExpectedErr != nil { ft.assertError(c, err) } else { ft.assertNoError(c, err) - ft.assertCLI(c, b) ft.assertLog(c, b) } }