-
-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad3c382
commit fc6e9eb
Showing
22 changed files
with
340 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package action | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"flag" | ||
"os" | ||
"testing" | ||
|
||
"github.com/justwatchcom/gopass/pkg/ctxutil" | ||
"github.com/justwatchcom/gopass/pkg/out" | ||
"github.com/justwatchcom/gopass/tests/gptest" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
func TestEdit(t *testing.T) { | ||
u := gptest.NewUnitTester(t) | ||
defer u.Remove() | ||
|
||
ctx := context.Background() | ||
ctx = ctxutil.WithAlwaysYes(ctx, true) | ||
ctx = ctxutil.WithTerminal(ctx, false) | ||
act, err := newMock(ctx, u) | ||
assert.NoError(t, err) | ||
|
||
buf := &bytes.Buffer{} | ||
out.Stdout = buf | ||
defer func() { | ||
out.Stdout = os.Stdout | ||
}() | ||
|
||
app := cli.NewApp() | ||
|
||
// edit | ||
c := cli.NewContext(app, flag.NewFlagSet("default", flag.ContinueOnError), nil) | ||
assert.Error(t, act.Edit(ctx, c)) | ||
buf.Reset() | ||
|
||
// edit foo | ||
fs := flag.NewFlagSet("default", flag.ContinueOnError) | ||
assert.NoError(t, fs.Parse([]string{"foo"})) | ||
c = cli.NewContext(app, fs, nil) | ||
|
||
assert.Error(t, act.Edit(ctx, c)) | ||
buf.Reset() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package action | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"flag" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/fatih/color" | ||
"github.com/justwatchcom/gopass/pkg/ctxutil" | ||
"github.com/justwatchcom/gopass/pkg/out" | ||
"github.com/justwatchcom/gopass/tests/gptest" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
func TestFsck(t *testing.T) { | ||
u := gptest.NewUnitTester(t) | ||
defer u.Remove() | ||
|
||
ctx := context.Background() | ||
ctx = ctxutil.WithTerminal(ctx, false) | ||
act, err := newMock(ctx, u) | ||
assert.NoError(t, err) | ||
|
||
buf := &bytes.Buffer{} | ||
out.Stdout = buf | ||
stdout = buf | ||
defer func() { | ||
stdout = os.Stdout | ||
out.Stdout = os.Stdout | ||
}() | ||
color.NoColor = true | ||
|
||
app := cli.NewApp() | ||
|
||
// fsck | ||
c := cli.NewContext(app, flag.NewFlagSet("default", flag.ContinueOnError), nil) | ||
assert.NoError(t, act.Fsck(ctx, c)) | ||
|
||
// fsck fo | ||
fs := flag.NewFlagSet("default", flag.ContinueOnError) | ||
assert.NoError(t, fs.Parse([]string{"fo"})) | ||
c = cli.NewContext(app, fs, nil) | ||
|
||
assert.NoError(t, act.Fsck(ctx, c)) | ||
assert.Equal(t, "Extra recipients on foo: [0xFEEDBEEF]\nPushed changes to git remote\nExtra recipients on foo: [0xFEEDBEEF]\nPushed changes to git remote", strings.TrimSpace(buf.String())) | ||
buf.Reset() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.