An attempt at a new low level keybase interface that prevents each command from re-spawning a new keybase instance on low memory systems.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
953 B

package keybase
import (
"reflect"
"testing"
)
func TestBuildArgs(t *testing.T) {
cases := []struct {
Opts Options
Args []string
Expected []string
}{
{
Opts: Options{HomeDir: "/home/foo"},
Args: []string{"arg1"},
Expected: []string{"--home", "/home/foo", "--enable-bot-lite-mode", "arg1"},
},
{
Opts: Options{HomeDir: "/home/foo"},
Args: []string{"arg1", "arg2"},
Expected: []string{"--home", "/home/foo", "--enable-bot-lite-mode", "arg1", "arg2"},
},
{
Opts: Options{HomeDir: "/home/foo", DisableLiteMode: true},
Args: []string{"arg1"},
Expected: []string{"--home", "/home/foo", "arg1"},
},
}
for i, c := range cases {
actual, err := buildArgs(c.Opts, c.Args...)
if err != nil {
t.Errorf("[case %d] returned error: %v", i, err)
}
if !reflect.DeepEqual(actual, c.Expected) {
t.Errorf("[case %d] expected: %#v, got: %#v", i, c.Expected, actual)
}
}
}