зеркало из https://github.com/mislav/hub.git
31 строка
716 B
Go
31 строка
716 B
Go
package commands
|
|
|
|
import (
|
|
"github.com/bmizerany/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewArgs(t *testing.T) {
|
|
args := NewArgs([]string{})
|
|
assert.Equal(t, "", args.Command)
|
|
assert.Equal(t, 0, args.ParamsSize())
|
|
|
|
args = NewArgs([]string{"command"})
|
|
assert.Equal(t, "command", args.Command)
|
|
assert.Equal(t, 0, args.ParamsSize())
|
|
|
|
args = NewArgs([]string{"command", "args"})
|
|
assert.Equal(t, "command", args.Command)
|
|
assert.Equal(t, 1, args.ParamsSize())
|
|
}
|
|
|
|
func TestRemove(t *testing.T) {
|
|
args := NewArgs([]string{"1", "2", "3", "4"})
|
|
|
|
item := args.RemoveParam(1)
|
|
assert.Equal(t, "3", item)
|
|
assert.Equal(t, 2, args.ParamsSize())
|
|
assert.Equal(t, "2", args.FirstParam())
|
|
assert.Equal(t, "4", args.GetParam(1))
|
|
}
|