Skip to content

Commit 030b732

Browse files
committed
[#200] Simplify vcs/p4 global parameters tests
1 parent 55d355d commit 030b732

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/vcs/p4/p4_impl_test.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -513,23 +513,25 @@ func Test_convert_to_p4_client_path(t *testing.T) {
513513
}
514514

515515
func Test_p4_run_command_global_parameters(t *testing.T) {
516-
p, _ := newP4Impl(inMemoryDepotInit, "/basedir", true)
516+
p, _ := newP4Impl(inMemoryDepotInit, filepath.FromSlash("/basedir"), true)
517517
p.clientName = "test_client"
518+
var cmdParams []string
518519
p.runP4Function = func(params ...string) (out []byte, err error) {
519-
return []byte(fmt.Sprintf("%v", params)), nil
520+
cmdParams = params
521+
return nil, nil
520522
}
521-
output, _ := p.runP4()
522-
assert.Equal(t, "[-d /basedir -c test_client]", string(output))
523+
_, _ = p.runP4()
524+
assert.Equal(t, []string{"-d", filepath.FromSlash("/basedir"), "-c", "test_client"}, cmdParams)
523525
}
524526

525527
func Test_p4_trace_command_global_parameters(t *testing.T) {
526-
p, _ := newP4Impl(inMemoryDepotInit, "/basedir", true)
528+
p, _ := newP4Impl(inMemoryDepotInit, filepath.FromSlash("/basedir"), true)
527529
p.clientName = "test_client"
528-
var trace string
530+
var cmdParams []string
529531
p.traceP4Function = func(params ...string) (err error) {
530-
trace = fmt.Sprintf("%v", params)
532+
cmdParams = params
531533
return nil
532534
}
533535
_ = p.traceP4()
534-
assert.Equal(t, "[-d /basedir -c test_client]", trace)
536+
assert.Equal(t, []string{"-d", filepath.FromSlash("/basedir"), "-c", "test_client"}, cmdParams)
535537
}

0 commit comments

Comments
 (0)