Use global context

This commit is contained in:
Volodymyr Zotov
2025-06-08 10:28:15 -05:00
parent ac06f8db13
commit efbe96e93a
17 changed files with 150 additions and 136 deletions

View File

@@ -1,6 +1,7 @@
package mocks
import (
"context"
"github.com/stretchr/testify/mock"
"github.com/1Password/onepassword-operator/pkg/onepassword/model"
@@ -10,7 +11,7 @@ type TestClient struct {
mock.Mock
}
func (tc *TestClient) GetItemByID(vaultID, itemID string) (*model.Item, error) {
func (tc *TestClient) GetItemByID(ctx context.Context, vaultID, itemID string) (*model.Item, error) {
args := tc.Called(vaultID, itemID)
if args.Get(0) == nil {
return nil, args.Error(1)
@@ -18,12 +19,12 @@ func (tc *TestClient) GetItemByID(vaultID, itemID string) (*model.Item, error) {
return args.Get(0).(*model.Item), args.Error(1)
}
func (tc *TestClient) GetItemsByTitle(vaultID, itemTitle string) ([]model.Item, error) {
func (tc *TestClient) GetItemsByTitle(ctx context.Context, vaultID, itemTitle string) ([]model.Item, error) {
args := tc.Called(vaultID, itemTitle)
return args.Get(0).([]model.Item), args.Error(1)
}
func (tc *TestClient) GetFileContent(vaultID, itemID, fileID string) ([]byte, error) {
func (tc *TestClient) GetFileContent(ctx context.Context, vaultID, itemID, fileID string) ([]byte, error) {
args := tc.Called(vaultID, itemID, fileID)
if args.Get(0) == nil {
return nil, args.Error(1)
@@ -31,7 +32,7 @@ func (tc *TestClient) GetFileContent(vaultID, itemID, fileID string) ([]byte, er
return args.Get(0).([]byte), args.Error(1)
}
func (tc *TestClient) GetVaultsByTitle(title string) ([]model.Vault, error) {
func (tc *TestClient) GetVaultsByTitle(ctx context.Context, title string) ([]model.Vault, error) {
args := tc.Called(title)
return args.Get(0).([]model.Vault), args.Error(1)
}