Skip to content

Commit 63ac2a4

Browse files
committed
store/keychain(test): refactor mock credential types
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
1 parent ecd1f81 commit 63ac2a4

1 file changed

Lines changed: 24 additions & 28 deletions

File tree

store/keychain/keychain_test.go

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ import (
99
"github.com/stretchr/testify/require"
1010
)
1111

12+
type mustMarshalError struct{}
13+
14+
var _ store.Secret = &mustMarshalError{}
15+
16+
func (m *mustMarshalError) Marshal() ([]byte, error) {
17+
return nil, errors.New("i am failing on purpose")
18+
}
19+
20+
func (m *mustMarshalError) Unmarshal(data []byte) error {
21+
return nil
22+
}
23+
24+
type mustUnmarshalError struct{}
25+
26+
var _ store.Secret = &mustUnmarshalError{}
27+
28+
func (m *mustUnmarshalError) Marshal() ([]byte, error) {
29+
return []byte("eeyyy"), nil
30+
}
31+
32+
func (m *mustUnmarshalError) Unmarshal(data []byte) error {
33+
return errors.New("i am failing on purpose")
34+
}
35+
1236
func setupKeychain(t *testing.T, secretFactory func() store.Secret) store.Store {
1337
t.Helper()
1438
if secretFactory == nil {
@@ -176,31 +200,3 @@ func TestKeychain(t *testing.T) {
176200
require.ErrorContains(t, err, "i am failing on purpose")
177201
})
178202
}
179-
180-
type mustMarshalError struct{}
181-
182-
// Marshal implements store.Secret.
183-
func (m *mustMarshalError) Marshal() ([]byte, error) {
184-
return nil, errors.New("i am failing on purpose")
185-
}
186-
187-
// Unmarshal implements store.Secret.
188-
func (m *mustMarshalError) Unmarshal(data []byte) error {
189-
return nil
190-
}
191-
192-
var _ store.Secret = &mustMarshalError{}
193-
194-
type mustUnmarshalError struct{}
195-
196-
// Marshal implements store.Secret.
197-
func (m *mustUnmarshalError) Marshal() ([]byte, error) {
198-
return []byte("eeyyy"), nil
199-
}
200-
201-
// Unmarshal implements store.Secret.
202-
func (m *mustUnmarshalError) Unmarshal(data []byte) error {
203-
return errors.New("i am failing on purpose")
204-
}
205-
206-
var _ store.Secret = &mustUnmarshalError{}

0 commit comments

Comments
 (0)