mirror of
https://github.com/restic/restic.git
synced 2024-12-22 15:57:07 +00:00
key: fix integration test for invalid arguments
This commit is contained in:
parent
795d33b3ee
commit
e46b21ab80
1 changed files with 7 additions and 11 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/backend"
|
"github.com/restic/restic/internal/backend"
|
||||||
|
@ -154,26 +155,21 @@ func TestKeyCommandInvalidArguments(t *testing.T) {
|
||||||
|
|
||||||
err := runKeyAdd(context.TODO(), env.gopts, KeyAddOptions{}, []string{"johndoe"})
|
err := runKeyAdd(context.TODO(), env.gopts, KeyAddOptions{}, []string{"johndoe"})
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
rtest.Assert(t, err != nil, "expected key add to fail")
|
rtest.Assert(t, err != nil && strings.Contains(err.Error(), "no arguments"), "unexpected error for key add: %v", err)
|
||||||
|
|
||||||
testKeyNewPassword = "johndoe"
|
|
||||||
defer func() {
|
|
||||||
testKeyNewPassword = ""
|
|
||||||
}()
|
|
||||||
err = runKeyPasswd(context.TODO(), env.gopts, KeyPasswdOptions{}, []string{"johndoe"})
|
err = runKeyPasswd(context.TODO(), env.gopts, KeyPasswdOptions{}, []string{"johndoe"})
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
rtest.Assert(t, err != nil, "expected key passwd to fail")
|
rtest.Assert(t, err != nil && strings.Contains(err.Error(), "no arguments"), "unexpected error for key passwd: %v", err)
|
||||||
|
|
||||||
env.gopts.password = "johndoe"
|
err = runKeyList(context.TODO(), env.gopts, []string{"johndoe"})
|
||||||
err = runKeyList(context.TODO(), env.gopts, []string{})
|
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
rtest.Assert(t, err != nil, "expected key list to fail")
|
rtest.Assert(t, err != nil && strings.Contains(err.Error(), "no arguments"), "unexpected error for key list: %v", err)
|
||||||
|
|
||||||
err = runKeyRemove(context.TODO(), env.gopts, []string{})
|
err = runKeyRemove(context.TODO(), env.gopts, []string{})
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
rtest.Assert(t, err != nil, "expected key remove to fail")
|
rtest.Assert(t, err != nil && strings.Contains(err.Error(), "one argument"), "unexpected error for key remove: %v", err)
|
||||||
|
|
||||||
err = runKeyRemove(context.TODO(), env.gopts, []string{"john", "doe"})
|
err = runKeyRemove(context.TODO(), env.gopts, []string{"john", "doe"})
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
rtest.Assert(t, err != nil, "expected key remove to fail")
|
rtest.Assert(t, err != nil && strings.Contains(err.Error(), "one argument"), "unexpected error for key remove: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue