Apply linter autofixes: internal/vaultik (refs #61)
This commit is contained in:
@@ -37,7 +37,9 @@ func (s *testStorer) Put(ctx context.Context, key string, reader io.Reader) erro
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.data[key] = data
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -53,6 +55,7 @@ func (s *testStorer) Get(ctx context.Context, key string) (io.ReadCloser, error)
|
||||
if !exists {
|
||||
return nil, storage.ErrNotFound
|
||||
}
|
||||
|
||||
return io.NopCloser(bytes.NewReader(data)), nil
|
||||
}
|
||||
|
||||
@@ -64,6 +67,7 @@ func (s *testStorer) Stat(ctx context.Context, key string) (*storage.ObjectInfo,
|
||||
if !exists {
|
||||
return nil, storage.ErrNotFound
|
||||
}
|
||||
|
||||
return &storage.ObjectInfo{
|
||||
Key: key,
|
||||
Size: int64(len(data)),
|
||||
@@ -75,6 +79,7 @@ func (s *testStorer) Delete(ctx context.Context, key string) error {
|
||||
defer s.mu.Unlock()
|
||||
|
||||
delete(s.data, key)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -83,11 +88,13 @@ func (s *testStorer) List(ctx context.Context, prefix string) ([]string, error)
|
||||
defer s.mu.Unlock()
|
||||
|
||||
var keys []string
|
||||
|
||||
for key := range s.data {
|
||||
if prefix == "" || strings.HasPrefix(key, prefix) {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
}
|
||||
|
||||
return keys, nil
|
||||
}
|
||||
|
||||
@@ -96,6 +103,7 @@ func (s *testStorer) ListStream(ctx context.Context, prefix string) <-chan stora
|
||||
|
||||
go func() {
|
||||
defer close(ch)
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
@@ -115,13 +123,16 @@ func (s *testStorer) ListStream(ctx context.Context, prefix string) <-chan stora
|
||||
func (s *testStorer) hasKey(key string) bool {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
_, exists := s.data[key]
|
||||
|
||||
return exists
|
||||
}
|
||||
|
||||
func (s *testStorer) keyCount() int {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
return len(s.data)
|
||||
}
|
||||
|
||||
@@ -175,6 +186,7 @@ func addBlob(t *testing.T, store *testStorer, hash string) {
|
||||
|
||||
// Create zstd compressed data
|
||||
var buf bytes.Buffer
|
||||
|
||||
writer, _ := zstd.NewWriter(&buf)
|
||||
_, _ = writer.Write([]byte("blob data"))
|
||||
_ = writer.Close()
|
||||
@@ -366,7 +378,7 @@ func TestRemoveAllSnapshots_NoSnapshots(t *testing.T) {
|
||||
result, err := tv.RemoveAllSnapshots(opts)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, result.SnapshotsRemoved, 0)
|
||||
assert.Empty(t, result.SnapshotsRemoved)
|
||||
|
||||
// Verify output
|
||||
assert.Contains(t, tv.Stdout.String(), "No snapshots found")
|
||||
|
||||
Reference in New Issue
Block a user