Skip to content

Commit d03befe

Browse files
committed
command: adjust test for configPath returned by BuildCommand
Signed-off-by: Bin Tang <[email protected]>
1 parent 7956344 commit d03befe

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pkg/daemon/command/command_builder_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,26 @@ func TestBuildCommand(t *testing.T) {
1919
WithFscacheDriver("fs_cache_dir"),
2020
WithFscacheThreads(4),
2121
WithAPISock("/dummy/apisock"),
22-
WithUpgrade()}
22+
WithUpgrade(),
23+
WithConfig("testpath.json")}
2324

24-
args, err := BuildCommand(c)
25+
args, configPath, err := BuildCommand(c)
2526
assert.Nil(t, err)
2627
actual := strings.Join(args, " ")
27-
assert.Equal(t, "singleton --fscache fs_cache_dir --fscache-threads 4 --upgrade --apisock /dummy/apisock", actual)
28+
assert.Equal(t, "singleton --fscache fs_cache_dir --fscache-threads 4 --upgrade --config testpath.json --apisock /dummy/apisock", actual)
29+
assert.Equal(t, configPath, "testpath.json")
2830

2931
c1 := []Opt{WithMode("singleton"),
3032
WithFscacheDriver("fs_cache_dir"),
3133
WithFscacheThreads(4),
32-
WithAPISock("/dummy/apisock")}
34+
WithAPISock("/dummy/apisock"),
35+
WithConfig("testpath.json")}
3336

34-
args1, err := BuildCommand(c1)
37+
args1, configPath1, err := BuildCommand(c1)
3538
assert.Nil(t, err)
3639
actual1 := strings.Join(args1, " ")
37-
assert.Equal(t, "singleton --fscache fs_cache_dir --fscache-threads 4 --apisock /dummy/apisock", actual1)
40+
assert.Equal(t, "singleton --fscache fs_cache_dir --fscache-threads 4 --config testpath.json --apisock /dummy/apisock", actual1)
41+
assert.Equal(t, configPath1, "testpath.json")
3842
}
3943

4044
// cpu: Intel(R) Xeon(R) Platinum 8260 CPU @ 2.40GHz
@@ -50,7 +54,7 @@ func BenchmarkBuildCommand(b *testing.B) {
5054
WithUpgrade()}
5155

5256
for n := 0; n < b.N; n++ {
53-
_, err := BuildCommand(c)
57+
_, _, err := BuildCommand(c)
5458
assert.Nil(b, err)
5559
}
5660
}

0 commit comments

Comments
 (0)