From 0516159ae38e9f9396ea2c16521c9e69dfa5b21f Mon Sep 17 00:00:00 2001 From: huangqian Date: Mon, 28 Feb 2022 21:11:53 +0800 Subject: [PATCH] Improving gcmd Code Coverage --- os/gcmd/gcmd_z_unit_feature_object1_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/os/gcmd/gcmd_z_unit_feature_object1_test.go b/os/gcmd/gcmd_z_unit_feature_object1_test.go index dcde693de..4027b7fb1 100644 --- a/os/gcmd/gcmd_z_unit_feature_object1_test.go +++ b/os/gcmd/gcmd_z_unit_feature_object1_test.go @@ -63,6 +63,21 @@ func Test_Command_NewFromObject_Help(t *testing.T) { }) } +func Test_Command_NewFromObject_Run(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + ctx = gctx.New() + cmd, err = gcmd.NewFromObject(&TestCmdObject{}) + ) + t.AssertNil(err) + t.Assert(cmd.Name, "root") + + os.Args = []string{"root", "test", "-n=john"} + + cmd.Run(ctx) + }) +} + func Test_Command_NewFromObject_RunWithValue(t *testing.T) { gtest.C(t, func(t *gtest.T) { var (