From 824c86605906023ccf3cc2b108246e66b813eabc Mon Sep 17 00:00:00 2001 From: Bin Tang Date: Fri, 21 Jul 2023 20:11:04 +0800 Subject: [PATCH] command: adjust test for configPath returned by BuildCommand Signed-off-by: Bin Tang --- pkg/daemon/command/command_builder_test.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/daemon/command/command_builder_test.go b/pkg/daemon/command/command_builder_test.go index 62fea17c4d..ebf6a9681d 100644 --- a/pkg/daemon/command/command_builder_test.go +++ b/pkg/daemon/command/command_builder_test.go @@ -19,22 +19,26 @@ func TestBuildCommand(t *testing.T) { WithFscacheDriver("fs_cache_dir"), WithFscacheThreads(4), WithAPISock("/dummy/apisock"), - WithUpgrade()} + WithUpgrade(), + WithConfig("testpath.json")} - args, err := BuildCommand(c) + args, configPath, err := BuildCommand(c) assert.Nil(t, err) actual := strings.Join(args, " ") - assert.Equal(t, "singleton --fscache fs_cache_dir --fscache-threads 4 --upgrade --apisock /dummy/apisock", actual) + assert.Equal(t, "singleton --fscache fs_cache_dir --fscache-threads 4 --upgrade --config testpath.json --apisock /dummy/apisock", actual) + assert.Equal(t, configPath, "testpath.json") c1 := []Opt{WithMode("singleton"), WithFscacheDriver("fs_cache_dir"), WithFscacheThreads(4), - WithAPISock("/dummy/apisock")} + WithAPISock("/dummy/apisock"), + WithConfig("testpath.json")} - args1, err := BuildCommand(c1) + args1, configPath1, err := BuildCommand(c1) assert.Nil(t, err) actual1 := strings.Join(args1, " ") - assert.Equal(t, "singleton --fscache fs_cache_dir --fscache-threads 4 --apisock /dummy/apisock", actual1) + assert.Equal(t, "singleton --fscache fs_cache_dir --fscache-threads 4 --config testpath.json --apisock /dummy/apisock", actual1) + assert.Equal(t, configPath1, "testpath.json") } // cpu: Intel(R) Xeon(R) Platinum 8260 CPU @ 2.40GHz @@ -50,7 +54,7 @@ func BenchmarkBuildCommand(b *testing.B) { WithUpgrade()} for n := 0; n < b.N; n++ { - _, err := BuildCommand(c) + _, _, err := BuildCommand(c) assert.Nil(b, err) } }