Skip to content

Commit d19d78b

Browse files
Fix/tests (gopasspw#1151)
* Fix tests Signed-off-by: Dominik Schulz <[email protected]> * Update deps Signed-off-by: Dominik Schulz <[email protected]>
1 parent a37f7be commit d19d78b

File tree

400 files changed

+84098
-25173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

400 files changed

+84098
-25173
lines changed

Gopkg.lock

Lines changed: 72 additions & 380 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

commands_test.go

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,38 @@ import (
2323
// commandsWithError is a list of commands that return an error when
2424
// invoked without arguments
2525
var commandsWithError = map[string]struct{}{
26-
".audit": {},
27-
".audit.hibp": {},
28-
".binary.cat": {},
29-
".binary.copy": {},
30-
".binary.move": {},
31-
".binary.sum": {},
32-
".clone": {},
33-
".copy": {},
34-
".create": {},
35-
".delete": {},
36-
".edit": {},
37-
".find": {},
38-
".generate": {},
39-
".git.push": {},
40-
".git.remote.add": {},
41-
".git.remote.remove": {},
42-
".grep": {},
43-
".history": {},
44-
".init": {},
45-
".insert": {},
46-
".mounts.add": {},
47-
".mounts.remove": {},
48-
".move": {},
49-
".otp": {},
50-
".recipients.add": {},
51-
".recipients.remove": {},
52-
".setup": {},
53-
".show": {},
54-
".templates.edit": {},
55-
".templates.remove": {},
56-
".templates.show": {},
57-
".unclip": {},
58-
".xc.decrypt": {},
59-
".xc.encrypt": {},
60-
".xc.export": {},
61-
".xc.export-private-key": {},
62-
".xc.generate": {},
63-
".xc.import": {},
64-
".xc.import-private-key": {},
65-
".xc.remove": {},
26+
".audit": {},
27+
".audit.hibp": {},
28+
".binary.cat": {},
29+
".binary.copy": {},
30+
".binary.move": {},
31+
".binary.sum": {},
32+
".clone": {},
33+
".copy": {},
34+
".create": {},
35+
".delete": {},
36+
".edit": {},
37+
".find": {},
38+
".generate": {},
39+
".git.push": {},
40+
".git.remote.add": {},
41+
".git.remote.remove": {},
42+
".grep": {},
43+
".history": {},
44+
".init": {},
45+
".insert": {},
46+
".mounts.add": {},
47+
".mounts.remove": {},
48+
".move": {},
49+
".otp": {},
50+
".recipients.add": {},
51+
".recipients.remove": {},
52+
".setup": {},
53+
".show": {},
54+
".templates.edit": {},
55+
".templates.remove": {},
56+
".templates.show": {},
57+
".unclip": {},
6658
}
6759

6860
func TestGetCommands(t *testing.T) {

commands_xc_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// +build xc
2+
3+
package main
4+
5+
func init() {
6+
for _, cmd := range []string{
7+
".xc.decrypt",
8+
".xc.encrypt",
9+
".xc.export",
10+
".xc.export-private-key",
11+
".xc.generate",
12+
".xc.import",
13+
".xc.import-private-key",
14+
".xc.remove",
15+
} {
16+
commandsWithError[cmd] = struct{}{}
17+
}
18+
}

pkg/backend/context_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ func TestCryptoBackend(t *testing.T) {
1111
ctx := context.Background()
1212

1313
assert.Equal(t, GPGCLI, GetCryptoBackend(ctx))
14-
assert.Equal(t, XC, GetCryptoBackend(WithCryptoBackendString(ctx, "xc")))
15-
assert.Equal(t, XC, GetCryptoBackend(WithCryptoBackend(ctx, XC)))
16-
assert.Equal(t, true, HasCryptoBackend(WithCryptoBackend(ctx, XC)))
14+
assert.Equal(t, GPGCLI, GetCryptoBackend(WithCryptoBackendString(ctx, "gpgcli")))
15+
assert.Equal(t, GPGCLI, GetCryptoBackend(WithCryptoBackend(ctx, GPGCLI)))
16+
assert.Equal(t, true, HasCryptoBackend(WithCryptoBackend(ctx, GPGCLI)))
1717
}
1818

1919
func TestRCSBackend(t *testing.T) {

pkg/store/sub/git_gogit_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// +build gogit
2+
3+
package sub
4+
5+
import (
6+
"context"
7+
"io/ioutil"
8+
"os"
9+
"testing"
10+
11+
"github.com/gopasspw/gopass/pkg/backend"
12+
"github.com/gopasspw/gopass/pkg/ctxutil"
13+
"github.com/stretchr/testify/assert"
14+
"github.com/stretchr/testify/require"
15+
)
16+
17+
func TestGoGit(t *testing.T) {
18+
ctx := context.Background()
19+
20+
tempdir, err := ioutil.TempDir("", "gopass-")
21+
require.NoError(t, err)
22+
defer func() {
23+
_ = os.RemoveAll(tempdir)
24+
}()
25+
26+
s, err := createSubStore(tempdir)
27+
require.NoError(t, err)
28+
29+
assert.NotNil(t, s.RCS())
30+
assert.Equal(t, "noop", s.RCS().Name())
31+
assert.NoError(t, s.RCS().InitConfig(ctx, "foo", "[email protected]"))
32+
33+
assert.NoError(t, s.GitInit(ctx, "", ""))
34+
assert.NoError(t, s.GitInit(backend.WithRCSBackend(ctx, backend.Noop), "", ""))
35+
assert.NoError(t, s.GitInit(backend.WithRCSBackend(ctx, backend.GoGit), "", ""))
36+
assert.Error(t, s.GitInit(backend.WithRCSBackend(ctx, -1), "", ""))
37+
38+
ctx = ctxutil.WithDebug(ctx, true)
39+
assert.NoError(t, s.GitInit(backend.WithRCSBackend(ctx, backend.GitCLI), "Foo Bar", "[email protected]"))
40+
}

pkg/store/sub/git_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func TestGit(t *testing.T) {
3636

3737
assert.NoError(t, s.GitInit(ctx, "", ""))
3838
assert.NoError(t, s.GitInit(backend.WithRCSBackend(ctx, backend.Noop), "", ""))
39-
assert.NoError(t, s.GitInit(backend.WithRCSBackend(ctx, backend.GoGit), "", ""))
4039
assert.Error(t, s.GitInit(backend.WithRCSBackend(ctx, -1), "", ""))
4140

4241
ctx = ctxutil.WithDebug(ctx, true)

pkg/store/sub/store_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,56 +148,57 @@ func TestNew(t *testing.T) {
148148
}()
149149

150150
for _, tc := range []struct {
151+
dsc string
151152
ctx context.Context
152153
ok bool
153154
}{
154155
{
156+
dsc: "InMem Storage",
155157
ctx: backend.WithStorageBackend(ctx, backend.InMem),
156158
ok: true,
157159
},
158160
{
161+
dsc: "Invalid Storage",
159162
ctx: backend.WithStorageBackend(ctx, -1),
160163
ok: false,
161164
},
162165
{
163-
ctx: backend.WithRCSBackend(ctx, backend.GoGit),
164-
ok: true,
165-
},
166-
{
166+
dsc: "GitCLI RCS",
167167
ctx: backend.WithRCSBackend(ctx, backend.GitCLI),
168168
ok: true,
169169
},
170170
{
171+
dsc: "Noop RCS",
171172
ctx: backend.WithRCSBackend(ctx, backend.Noop),
172173
ok: true,
173174
},
174175
{
176+
dsc: "Invalid RCS",
175177
ctx: backend.WithRCSBackend(ctx, -1),
176178
ok: false,
177179
},
178180
{
181+
dsc: "GPG Crypto",
179182
ctx: backend.WithCryptoBackend(ctx, backend.GPGCLI),
180183
ok: true,
181184
},
182185
{
183-
ctx: backend.WithCryptoBackend(ctx, backend.XC),
184-
ok: true,
185-
},
186-
{
186+
dsc: "Plain Crypto",
187187
ctx: backend.WithCryptoBackend(ctx, backend.Plain),
188188
ok: true,
189189
},
190190
{
191+
dsc: "Invalid Crypto",
191192
ctx: backend.WithCryptoBackend(ctx, -1),
192193
ok: false,
193194
},
194195
} {
195196
s, err := New(tc.ctx, nil, "", backend.FromPath(tempdir), tempdir, nil)
196197
if tc.ok {
197-
assert.NoError(t, err)
198-
assert.NotNil(t, s)
198+
assert.NoError(t, err, tc.dsc)
199+
assert.NotNil(t, s, tc.dsc)
199200
} else {
200-
assert.Error(t, err)
201+
assert.Error(t, err, tc.dsc)
201202
}
202203
}
203204
}

vendor/github.com/armon/go-metrics/.travis.yml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/armon/go-metrics/go.mod

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/armon/go-metrics/go.sum

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)