You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: write_test.go
    path of file: ./repos/openfga/pkg/server/commands
    
    the code of the file until where you have to start completion: package commands

import (
	"context"
	"fmt"
	"testing"

	"github.com/oklog/ulid/v2"
	openfgav1 "github.com/openfga/api/proto/openfga/v1"
	"github.com/stretchr/testify/require"
	"go.uber.org/mock/gomock"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	"google.golang.org/protobuf/proto"

	mockstorage "github.com/openfga/openfga/internal/mocks"
	"github.com/openfga/openfga/internal/server/config"
	serverErrors "github.com/openfga/openfga/pkg/server/errors"
	"github.com/openfga/openfga/pkg/storage"
	"github.com/openfga/openfga/pkg/testutils"
	"github.com/openfga/openfga/pkg/tuple"
	"github.com/openfga/openfga/pkg/typesystem"
)

func TestValidateNoDuplicatesAndCorrectSize(t *testing.T) {
	type test struct {
		name          string
		deletes       []*openfgav1.TupleKeyWithoutCondition
		writes        []*openfgav1.TupleKey
		expectedError error
	}

	mockController := gomock.NewController(t)
	defer mockController.Finish()

	maxTuplesInWriteOp := 10
	mockDatastore := mockstorage.NewMockOpenFGADatastore(mockController)
	mockDatastore.EXPECT().MaxTuplesPerWrite().AnyTimes().Return(maxTuplesInWriteOp)

	items := make([]*openfgav1.TupleKeyWithoutCondition, maxTuplesInWriteOp+1)
	for i := 0; i < maxTuplesInWriteOp+1; i++ {
		items[i] = &openfgav1.TupleKeyWithoutCondition{
			Object:   fmt.Sprintf("%s:1", testutils.CreateRandomString(459)),
			Relation: testutils.CreateRandomString(50),
			User:     testutils.CreateRandomString(512),
		}
	}

	cmd := NewWriteCommand(mockDatastore)

	tests := []test{
		{
			name:    "empty_deletes_and_writes",
			deletes: []*openfgav1.TupleKeyWithoutCondition{},
			writes:  []*openfgav1.TupleKey{},
		},
		{
			name:    "good_deletes_and_writes",
			deletes: []*openfgav1.TupleKeyWithoutCondition{items[0], items[1]},
			writes: []*openfgav1.TupleKey{
				tuple.TupleKeyWithoutConditionToTupleKey(items[2]),
				tuple.TupleKeyWithoutCon
    
func TestValidateNoDuplicatesAndCorrectSize(t *testing.T) {
	type test struct {
		name          string
		deletes       []*openfgav1.TupleKeyWithoutCondition
		writes        []*openfgav1.TupleKey
		expectedError error
	}

	mockController := gomock.NewController(t)
	defer mockController.Finish()

	maxTuplesInWriteOp := 10
	mockDatastore := mockstorage.NewMockOpenFGADatastore(mockController)
	mockDatastore.EXPECT().MaxTuplesPerWrite().AnyTimes().Return(maxTuplesInWriteOp)

	items := make([]*openfgav1.TupleKeyWithoutCondition, maxTuplesInWriteOp+1)
	for i := 0; i < maxTuplesInWriteOp+1; i++ {
		items[i] = &openfgav1.TupleKeyWithoutCondition{
			Object:   fmt.Sprintf("%s:1", testutils.CreateRandomString(459)),
			Relation: testutils.CreateRandomString(50),
			User:     testutils.CreateRandomString(512),
		}
	}

	cmd := NewWriteCommand(mockDatastore)

	tests := []test{
		{
			name:    "empty_deletes_and_writes",
			deletes: []*openfgav1.TupleKeyWithoutCondition{},
			writes:  []*openfgav1.TupleKey{},
		},
		{
			name:    "good_deletes_and_writes",
			deletes: []*openfgav1.TupleKeyWithoutCondition{items[0], items[1]},
			writes: []*openfgav1.TupleKey{
				tuple.TupleKeyWithoutConditionToTupleKey(items[2]),
				tuple.TupleKeyWithoutConditionToTupleKey(items[3]),
			},
		},
		{
			name:          "duplicate_deletes",
			deletes:       []*openfgav1.TupleKeyWithoutCondition{items[0], items[1], items[0]},
			writes:        []*openfgav1.TupleKey{},
			expectedError: serverErrors.DuplicateTupleInWrite(items[0]),
		},
		{
			name:    "duplicate_writes",
			deletes: []*openfgav1.TupleKeyWithoutCondition{},
			writes: []*openfgav1.TupleKey{
				tuple.TupleKeyWithoutConditionToTupleKey(items[0]),
				tuple.TupleKeyWithoutConditionToTupleKey(items[1]),
				tuple.TupleKeyWithoutConditionToTupleKey(items[0]),
			},
			expectedError: serverErrors.DuplicateTupleInWrite(items[0]),
		},
		{
			name:    "same_item_appeared_in_writes_and_deletes",
			deletes: []*openfgav1.TupleKeyWithoutCondition{items[2], items[1]},
			writes: []*openfgav1.TupleKey{
				tuple.TupleKeyWithoutConditionToTupleKey(items[0]),
				tuple.TupleKeyWithoutConditionToTupleKey(items[1]),
			},
			expectedError: serverErrors.DuplicateTupleInWrite(items[1]),
		},
		{
			name:          "too_many_items_writes_and_deletes",
			deletes:       items[:5],
			writes:        tuple.TupleKeysWithoutConditionToTupleKeys(items[5:]...),
			expectedError: serverErrors.ExceededEntityLimit("write operations", maxTuplesInWriteOp),
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			err := cmd.validateNoDuplicatesAndCorrectSize(test.deletes, test.writes)
			require.ErrorIs(t, err, test.expectedError)
		})
	}
}