Skip to content

Commit

Permalink
command: adjust test for configPath returned by BuildCommand
Browse files Browse the repository at this point in the history
Signed-off-by: Bin Tang <[email protected]>
  • Loading branch information
sctb512 committed Jul 27, 2023
1 parent 7956344 commit d03befe
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/daemon/command/command_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}

0 comments on commit d03befe

Please sign in to comment.