go-ceph/internal/cutil/command_input_test.go
Manish 6f90ce139c Code Lint: Fix lint errors caused by revive check for unused parameters
revive v1.3.7 added https://github.com/mgechev/revive/pull/966 which
checks for unused parameters in function literals. This caused several
lint errors in go-ceph code.

Signed-off-by: Manish <myathnal@redhat.com>
2024-02-13 07:22:13 +00:00

51 lines
1.1 KiB
Go

package cutil
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCommandInput(t *testing.T) {
t.Run("newAndFree", func(_ *testing.T) {
ci := NewCommandInput(
[][]byte{[]byte("foobar")},
nil)
ci.Free()
})
t.Run("cmd", func(t *testing.T) {
ci := NewCommandInput(
[][]byte{[]byte("foobar")},
nil)
defer ci.Free()
assert.Len(t, ci.cmd, 1)
assert.EqualValues(t, 1, ci.CmdLen())
assert.NotNil(t, ci.Cmd())
})
t.Run("cmd2", func(t *testing.T) {
ci := NewCommandInput(
[][]byte{[]byte("foobar"), []byte("snarf")},
nil)
defer ci.Free()
assert.Len(t, ci.cmd, 2)
assert.EqualValues(t, 2, ci.CmdLen())
assert.NotNil(t, ci.Cmd())
})
t.Run("noInBuf", func(t *testing.T) {
ci := NewCommandInput(
[][]byte{[]byte("foobar")},
nil)
defer ci.Free()
assert.EqualValues(t, 0, ci.InBufLen())
assert.Equal(t, CharPtr(nil), ci.InBuf())
})
t.Run("hasInBuf", func(t *testing.T) {
ci := NewCommandInput(
[][]byte{[]byte("foobar")},
[]byte("original oregano"))
defer ci.Free()
assert.EqualValues(t, 16, ci.InBufLen())
assert.NotEqual(t, CharPtr(nil), ci.InBuf())
})
}