<commit_before>package test

import (
	"context"

	"github.com/onsi/gomega"

	"github.com/tidepool-org/platform/data"
	dataStoreDEPRECATED "github.com/tidepool-org/platform/data/storeDEPRECATED"
	"github.com/tidepool-org/platform/data/types/upload"
	"github.com/tidepool-org/platform/page"
	"github.com/tidepool-org/platform/test"
)

type GetDataSetsForUserByIDInput struct {
	Context    context.Context
	UserID     string
	Filter     *dataStoreDEPRECATED.Filter
	Pagination *page.Pagination
}

type GetDataSetsForUserByIDOutput struct {
	DataSets []*upload.Upload
	Error    error
}

type GetDataSetByIDInput struct {
	Context   context.Context
	DataSetID string
}

type GetDataSetByIDOutput struct {
	DataSet *upload.Upload
	Error   error
}

type CreateDataSetInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type UpdateDataSetInput struct {
	Context context.Context
	ID      string
	Update  *data.DataSetUpdate
}

type UpdateDataSetOutput struct {
	DataSet *upload.Upload
	Error   error
}

type DeleteDataSetInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type CreateDataSetDataInput struct {
	Context     context.Context
	DataSet     *upload.Upload
	DataSetData []data.Datum
}

type ActivateDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type ArchiveDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type DeleteDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type DestroyDeletedDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type DestroyDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type ArchiveDeviceDataUsingHashesFromDataSetInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type UnarchiveDeviceDataUsingHashesFromDataSetInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type DeleteOtherDataSetDataInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type DestroyDataForUserByIDInput struct {
	Context context.Context
	UserID  string
}

type GetDataSetInput struct {
	Context context.Context
	ID      string
}

type GetDataSetOutput struct {
	DataSet *data.DataSet
	Error   error
}

type ListUserDataSetsInput struct {
	Context    context.Context
	UserID     string
	Filter     *data.DataSetFilter
	Pagination *page.Pagination
}

type ListUserDataSetsOutput struct {
	DataSets data.DataSets
	Error    error
}

type DataSession struct {
	*test.Closer
	GetDataSetsForUserByIDInvocations                    int
	GetDataSetsForUserByIDInputs                         []GetDataSetsForUserByIDInput
	GetDataSetsForUserByIDOutputs                        []GetDataSetsForUserByIDOutput
	GetDataSetByIDInvocations                            int
	GetDataSetByIDInputs                                 []GetDataSetByIDInput
	GetDataSetByIDOutputs                                []GetDataSetByIDOutput
	CreateDataSetInvocations                             int
	CreateDataSetInputs                                  []CreateDataSetInput
	CreateDataSetOutputs                                 []error
	UpdateDataSetInvocations                             int
	UpdateDataSetInputs                                  []UpdateDataSetInput
	UpdateDataSetOutputs                                 []UpdateDataSetOutput
	DeleteDataSetInvocations                             int
	DeleteDataSetInputs                                  []DeleteDataSetInput
	DeleteDataSetOutputs                                 []error
	CreateDataSetDataInvocations                         int
	CreateDataSetDataInputs                              []CreateDataSetDataInput
	CreateDataSetDataOutputs                             []error
	ActivateDataSetDataInvocations                       int
	ActivateDataSetDataInputs                            []ActivateDataSetDataInput
	ActivateDataSetDataOutputs                           []error
	ArchiveDataSetDataInvocations                        int
	ArchiveDataSetDataInputs                             []ArchiveDataSetDataInput
	ArchiveDataSetDataOutputs                            []error
	DeleteDataSetDataInvocations                         int
	DeleteDataSetDataInputs                              []DeleteDataSetDataInput
	DeleteDataSetDataOutputs                             []error
	DestroyDeletedDataSetDataInvocations                 int
	DestroyDeletedDataSetDataInputs                      []DestroyDeletedDataSetDataInput
	DestroyDeletedDataSetDataOutputs                     []error
	DestroyDataSetDataInvocations                        int
	DestroyDataSetDataInputs                             []DestroyDataSetDataInput
	DestroyDataSetDataOutputs                            []error
	ArchiveDeviceDataUsingHashesFromDataSetInvocations   int
	ArchiveDeviceDataUsingHashesFromDataSetInputs        []ArchiveDeviceDataUsingHashesFromDataSetInput
	ArchiveDeviceDataUsingHashesFromDataSetOutputs       []error
	UnarchiveDeviceDataUsingHashesFromDataSetInvocations int
	UnarchiveDeviceDataUsingHashesFromDataSetInputs      []UnarchiveDeviceDataUsingHashesFromDataSetInput
	UnarchiveDeviceDataUsingHashesFromDataSetOutputs     []error
	DeleteOtherDataSetDataInvocations                    int
	DeleteOtherDataSetDataInputs                         []DeleteOtherDataSetDataInput
	DeleteOtherDataSetDataOutputs                        []error
	DestroyDataForUserByIDInvocations                    int
	DestroyDataForUserByIDInputs                         []DestroyDataForUserByIDInput
	DestroyDataForUserByIDOutputs                        []error
	ListUserDataSetsInvocations                          int
	ListUserDataSetsInputs                               []ListUserDataSetsInput
	ListUserDataSetsOutputs                              []ListUserDataSetsOutput
	GetDataSetInvocations                                int
	GetDataSetInputs                                     []GetDataSetInput
	GetDataSetOutputs                                    []GetDataSetOutput
}

func NewDataSession() *DataSession {
	return &DataSession{
		Closer: test.NewCloser(),
	}
}

func (d *DataSession) GetDataSetsForUserByID(ctx context.Context, userID string, filter *dataStoreDEPRECATED.Filter, pagination *page.Pagination) ([]*upload.Upload, error) {
	d.GetDataSetsForUserByIDInvocations++

	d.GetDataSetsForUserByIDInputs = append(d.GetDataSetsForUserByIDInputs, GetDataSetsForUserByIDInput{Context: ctx, UserID: userID, Filter: filter, Pagination: pagination})

	gomega.Expect(d.GetDataSetsForUserByIDOutputs).ToNot(gomega.BeEmpty())

	output := d.GetDataSetsForUserByIDOutputs[0]
	d.GetDataSetsForUserByIDOutputs = d.GetDataSetsForUserByIDOutputs[1:]
	return output.DataSets, output.Error
}

func (d *DataSession) GetDataSetByID(ctx context.Context, dataSetID string) (*upload.Upload, error) {
	d.GetDataSetByIDInvocations++

	d.GetDataSetByIDInputs = append(d.GetDataSetByIDInputs, GetDataSetByIDInput{Context: ctx, DataSetID: dataSetID})

	gomega.Expect(d.GetDataSetByIDOutputs).ToNot(gomega.BeEmpty())

	output := d.GetDataSetByIDOutputs[0]
	d.GetDataSetByIDOutputs = d.GetDataSetByIDOutputs[1:]
	return output.DataSet, output.Error<commit_msg>Update to fix vet/test errors<commit_after>package test

import (
	"context"

	"github.com/onsi/gomega"

	"github.com/tidepool-org/platform/data"
	dataStoreDEPRECATED "github.com/tidepool-org/platform/data/storeDEPRECATED"
	"github.com/tidepool-org/platform/data/types/upload"
	"github.com/tidepool-org/platform/page"
	"github.com/tidepool-org/platform/test"
)

type GetDataSetsForUserByIDInput struct {
	Context    context.Context
	UserID     string
	Filter     *dataStoreDEPRECATED.Filter
	Pagination *page.Pagination
}

type GetDataSetsForUserByIDOutput struct {
	DataSets []*upload.Upload
	Error    error
}

type GetDataSetByIDInput struct {
	Context   context.Context
	DataSetID string
}

type GetDataSetByIDOutput struct {
	DataSet *upload.Upload
	Error   error
}

type CreateDataSetInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type UpdateDataSetInput struct {
	Context context.Context
	ID      string
	Update  *data.DataSetUpdate
}

type UpdateDataSetOutput struct {
	DataSet *upload.Upload
	Error   error
}

type DeleteDataSetInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type CreateDataSetDataInput struct {
	Context     context.Context
	DataSet     *upload.Upload
	DataSetData []data.Datum
}

type ActivateDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type ArchiveDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type DeleteDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type DestroyDeletedDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type DestroyDataSetDataInput struct {
	Context   context.Context
	DataSet   *upload.Upload
	Selectors *data.Selectors
}

type ArchiveDeviceDataUsingHashesFromDataSetInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type UnarchiveDeviceDataUsingHashesFromDataSetInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type DeleteOtherDataSetDataInput struct {
	Context context.Context
	DataSet *upload.Upload
}

type DestroyDataForUserByIDInput struct {
	Context context.Context
	UserID  string
}

type GetDataSetInput struct {
	Context context.Context
	ID      string
}

type GetDataSetOutput struct {
	DataSet *data.DataSet
	Error   error
}

type ListUserDataSetsInput struct {
	Context    context.Context
	UserID     string
	Filter     *data.DataSetFilter
	Pagination *page.Pagination
}

type ListUserDataSetsOutput struct {
	DataSets data.DataSets
	Error    error
}

type DataSession struct {
	*test.Closer
	GetDataSetsForUserByIDInvocations                    int
	GetDataSetsForUserByIDInputs                         []GetDataSetsForUserByIDInput
	GetDataSetsForUserByIDOutputs                        []GetDataSetsForUserByIDOutput
	GetDataSetByIDInvocations                            int
	GetDataSetByIDInputs                                 []GetDataSetByIDInput
	GetDataSetByIDOutputs                                []GetDataSetByIDOutput
	CreateDataSetInvocations                             int
	CreateDataSetInputs                                  []CreateDataSetInput
	CreateDataSetOutputs                                 []error
	UpdateDataSetInvocations                             int
	UpdateDataSetInputs                                  []UpdateDataSetInput
	UpdateDataSetOutputs                                 []UpdateDataSetOutput
	DeleteDataSetInvocations                             int
	DeleteDataSetInputs                                  []DeleteDataSetInput
	DeleteDataSetOutputs                                 []error
	CreateDataSetDataInvocations                         int
	CreateDataSetDataInputs                              []CreateDataSetDataInput
	CreateDataSetDataOutputs                             []error
	ActivateDataSetDataInvocations                       int
	ActivateDataSetDataInputs                            []ActivateDataSetDataInput
	ActivateDataSetDataOutputs                           []error
	ArchiveDataSetDataInvocations                        int
	ArchiveDataSetDataInputs                             []ArchiveDataSetDataInput
	ArchiveDataSetDataOutputs                            []error
	DeleteDataSetDataInvocations                         int
	DeleteDataSetDataInputs                              []DeleteDataSetDataInput
	DeleteDataSetDataOutputs                             []error
	DestroyDeletedDataSetDataInvocations                 int
	DestroyDeletedDataSetDataInputs                      []DestroyDeletedDataSetDataInput
	DestroyDeletedDataSetDataOutputs                     []error
	DestroyDataSetDataInvocations                        int
	DestroyDataSetDataInputs                             []DestroyDataSetDataInput
	DestroyDataSetDataOutputs                            []error
	ArchiveDeviceDataUsingHashesFromDataSetInvocations   int
	ArchiveDeviceDataUsingHashesFromDataSetInputs        []ArchiveDeviceDataUsingHashesFromDataSetInput
	ArchiveDeviceDataUsingHashesFromDataSetOutputs       []error
	UnarchiveDeviceDataUsingHashesFromDataSetInvocations int
	UnarchiveDeviceDataUsingHashesFromDataSetInputs      []UnarchiveDeviceDataUsingHashesFromDataSetInput
	UnarchiveDeviceDataUsingHashesFromDataSetOutputs     []error
	DeleteOtherDataSetDataInvocations                    int
	DeleteOtherDataSetDataInputs                         []DeleteOtherDataSetDataInput
	DeleteOtherDataSetDataOutputs                        []error
	DestroyDataForUserByIDInvocations                    int
	DestroyDataForUserByIDInputs                         []DestroyDataForUserByIDInput
	DestroyDataForUserByIDOutputs                        []error
	ListUserDataSetsInvocations                          int
	ListUserDataSetsInputs                               []ListUserDataSetsInput
	ListUserDataSetsOutputs                              []ListUserDataSetsOutput
	GetDataSetInvocations                                int
	GetDataSetInputs                                     []GetDataSetInput
	GetDataSetOutputs                                    []GetDataSetOutput
}

func NewDataSession() *DataSession {
	return &DataSession{
		Closer: test.NewCloser(),
	}
}

// EnsureIndexes required in order to implement the DataSession interface
func (s *DataSession) EnsureIndexes() error {
	return nil
}

func (d *DataSession) GetDataSetsForUserByID(ctx context.Context, userID string, filter *dataStoreDEPRECATED.Filter, pagination *page.Pagination) ([]*upload.Upload, error) {
	d.GetDataSetsForUserByIDInvocations++

	d.GetDataSetsForUserByIDInputs = append(d.GetDataSetsForUserByIDInputs, GetDataSetsForUserByIDInput{Context: ctx, UserID: userID, Filter: filter, Pagination: pagination})

	gomega.Expect(d.GetDataSetsForUserByIDOutputs).ToNot(gomega.BeEmpty())

	output := d.GetDataSetsForUserByIDOutputs[0]
	d.GetDataSetsForUserByIDOutputs = d.GetDataSetsForUserByIDOutputs[1:]
	return output.DataSets, output.Error
}

func (d *DataSession) GetDataSetByID(ctx context.Context, dataSetID string) (*upload.Upload, error) {
	d.GetDataSetByIDInvocations++

	d.GetDataSetByIDInputs = append(d.GetDataSetByIDInputs, GetDataSetByIDInput{Context: ctx, DataSetID: dataSetID})

	gomega.Expect(d.GetDataSetByIDOutputs).ToNot(gomega.BeEmpty())

	output := d.GetDataSetByIDOutputs[0]
	d.GetDataSetByIDOutputs = d.GetDataSetByIDOutputs[1:]
	return output.DataSet, output.Error
{'fraction_non_alphanumeric': 0.05023971908974272, 'fraction_numerical': 0.0005402120332230401, 'mean_word_length': 2.694188076827139, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4811360', 'n_tokens_mistral': 3888, 'n_tokens_neox': 4031, 'n_words': 731}