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: transaction_batch_test.go
    path of file: ./repos/azure-sdk-for-go/sdk/data/aztables
    
    the code of the file until where you have to start completion: // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package aztables

import (
	"encoding/json"
	"fmt"
	"testing"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/tracing"
	"github.com/Azure/azure-sdk-for-go/sdk/internal/recording"
	"github.com/stretchr/testify/require"
)

func TestBatchAdd(t *testing.T) {
	for _, service := range services {
		t.Run(fmt.Sprintf("%v_%v", t.Name(), service), func(t *testing.T) {
			client, deleteAndStop := initClientTest(t, service, true, NewSpanValidator(t, SpanMatcher{
				Name: "Client.SubmitTransaction",
			}))
			defer deleteAndStop()
			err := recording.SetBodilessMatcher(t, nil)
			require.NoError(t, err)
			err = recording.AddGeneralRegexSanitizer("batch_00000000-0000-0000-0000-000000000000", "batch_[0-9A-Fa-f]{8}[-]([0-9A-Fa-f]{4}[-]?){3}[0-9a-fA-F]{12}", nil)
			require.NoError(t, err)

			entitiesToCreate := createComplexEntities(10, "partition")
			var batch []TransactionAction

			for _, e := range entitiesToCreate {
				marshalled, err := json.Marshal(e)
				require.NoError(t, err)
				batch = append(batch, TransactionAction{ActionType: TransactionTypeAdd, Entity: marshalled})
			}

			_, err = client.SubmitTransaction(ctx, batch, nil)
			require.NoError(t, err)

			pager := client.NewListEntitiesPager(nil)
			count := 0
			for pager.More() {
				response, err := pager.NextPage(ctx)
				require.NoError(t, err)
				count += len(response.Entities)
			}

			require.Equal(t, count, 10)

		})
	}
}

func TestBatchInsert(t *testing.T) {
	for _, service := range services {
		t.Run(fmt.Sprintf("%v_%v", t.Name(), service), func(t *testing.T) {
			client, deleteAndStop := initClientTest(t, service, true, tracing.Provider{})
			defer deleteAndStop()
			err := recording.SetBodilessMatcher(t, nil)
			require.NoError(t, err)
			err = recording.AddGeneralRegexSanitizer("batch_00000000-0000-0000-0000-000000000000", "batch_[0-9A-Fa-f]{8}[-]([0-9A-Fa-f]{4}[-]?){3}[0-9a-fA-F]{12}", nil)
			require.NoError(t, err)

			entitiesToCreate := createComplexEntities(1, "partition")
			var batch []TransactionAction

			for _, e := range entitiesToCreate {
				marshalled, err := json.Marshal(e)
				require.NoError(t, err)
				batch = append(
					batch,
					TransactionAction{
						ActionType: TransactionTypeInsertMerge,
						Entity:     marshalled,
					},
				)
			}

			_, err = client.SubmitTransaction(ctx, batch, nil)
			require.NoError(t, err)

			pager := client.NewListEntitiesPager(nil)
			count := 0
			for pager.More() {
				response, err := pager.NextPage(ctx)
				require.NoError(t, err)
				count += len(response.Entities)
			}

			require.Equal(t, count, 1)
		})
	}
}

func TestBatchMixed(t *testing.T) {
	for _, service := range services {
		t.Run(fmt.Sprintf("%v_%v", t.Name(), service), func(t *testing.T) {
			client, deleteAndStop := initClientTest(t, service, true, tracing.Provider{})
			defer deleteAndStop()
			err := recording.SetBodilessMatcher(t, nil)
			require.NoError(t, err)
			err = recording.AddGeneralRegexSanitizer("batch_00000000-0000-0000-0000-000000000000", "batch_[0-9A-Fa-f]{8}[-]([0-9A-Fa-f]{4}[-]?){3}[0-9a-fA-F]{12}", nil)
			require.NoError(t, err)

			entitiesToCreate := createComplexEntities(5, "partition")
			var batch []TransactionAction

			for _, e := range entitiesToCreate {
				marshalled, err := json.Marshal(e)
				require.NoError(t, err)
				batch = append(batch, TransactionAction{
				
    
func TestBatchMixed(t *testing.T) {
	for _, service := range services {
		t.Run(fmt.Sprintf("%v_%v", t.Name(), service), func(t *testing.T) {
			client, deleteAndStop := initClientTest(t, service, true, tracing.Provider{})
			defer deleteAndStop()
			err := recording.SetBodilessMatcher(t, nil)
			require.NoError(t, err)
			err = recording.AddGeneralRegexSanitizer("batch_00000000-0000-0000-0000-000000000000", "batch_[0-9A-Fa-f]{8}[-]([0-9A-Fa-f]{4}[-]?){3}[0-9a-fA-F]{12}", nil)
			require.NoError(t, err)

			entitiesToCreate := createComplexEntities(5, "partition")
			var batch []TransactionAction

			for _, e := range entitiesToCreate {
				marshalled, err := json.Marshal(e)
				require.NoError(t, err)
				batch = append(batch, TransactionAction{
					ActionType: TransactionTypeAdd,
					Entity:     marshalled,
				})
			}

			_, err = client.SubmitTransaction(ctx, batch, nil)
			require.NoError(t, err)

			var qResp ListEntitiesResponse
			filter := "RowKey eq '1'"
			list := &ListEntitiesOptions{Filter: &filter}
			pager := client.NewListEntitiesPager(list)
			for pager.More() {
				qResp, err = pager.NextPage(ctx)
				require.NoError(t, err)
			}
			preMerge := qResp.Entities[0]
			var unMarshalledPreMerge map[string]any
			err = json.Unmarshal(preMerge, &unMarshalledPreMerge)
			require.NoError(t, err)

			// create a new batch slice.
			var batch2 []TransactionAction

			// create a merge action for the first added entity
			mergeProp := "MergeProperty"
			val := "foo"
			var mergeEntity = map[string]any{
				partitionKey: (entitiesToCreate)[0].PartitionKey,
				rowKey:       (entitiesToCreate)[0].RowKey,
				mergeProp:    val,
			}
			marshalledMergeEntity, err := json.Marshal(mergeEntity)
			require.NoError(t, err)
			batch2 = append(batch2, TransactionAction{
				ActionType: TransactionTypeUpdateMerge,
				Entity:     marshalledMergeEntity,
			})

			// create a delete action for the second added entity
			marshalledSecondEntity, err := json.Marshal((entitiesToCreate)[1])
			require.NoError(t, err)
			batch2 = append(batch2, TransactionAction{ActionType: TransactionTypeDelete, Entity: marshalledSecondEntity})

			// create an insert action to replace the third added entity with a new value
			replaceProp := "ReplaceProperty"
			var replaceProperties = map[string]any{
				partitionKey: (entitiesToCreate)[2].PartitionKey,
				rowKey:       (entitiesToCreate)[2].RowKey,
				replaceProp:  val,
			}
			marshalledThirdEntity, err := json.Marshal(replaceProperties)
			require.NoError(t, err)
			batch2 = append(batch2, TransactionAction{ActionType: TransactionTypeInsertReplace, Entity: marshalledThirdEntity})

			// Add the remaining 2 entities.
			marshalled4thEntity, err := json.Marshal((entitiesToCreate)[3])
			require.NoError(t, err)
			marshalled5thEntity, err := json.Marshal((entitiesToCreate)[4])
			require.NoError(t, err)
			batch2 = append(batch2, TransactionAction{ActionType: TransactionTypeUpdateMerge, Entity: marshalled4thEntity})
			batch2 = append(batch2, TransactionAction{ActionType: TransactionTypeInsertMerge, Entity: marshalled5thEntity})

			_, err = client.SubmitTransaction(ctx, batch2, nil)
			require.NoError(t, err)

			pager = client.NewListEntitiesPager(list)
			for pager.More() {
				qResp, err = pager.NextPage(ctx)
				require.NoError(t, err)
			}
			postMerge := qResp.Entities[0]
			var unMarshaledPostMerge map[string]any
			err = json.Unmarshal(postMerge, &unMarshaledPostMerge)
			require.NoError(t, err)

			// The merged entity has all its properties + the merged property
			require.Equalf(t, len(unMarshalledPreMerge)+1, len(unMarshaledPostMerge), "postMerge should have one more property than preMerge")
			require.Equalf(t, unMarshaledPostMerge[mergeProp], val, "%s property should equal %s", mergeProp, val)
		})
	}
}