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: mem_queue_test.go
    path of file: ./repos/cockroach/pkg/obsservice/obslib/queue
    
    the code of the file until where you have to start completion: // Copyright 2023 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0

package queue

import (
	"testing"

	"github.com/cockroachdb/cockroach/pkg/uti
    
func TestMemoryQueue_Dequeue(t *testing.T) {
	defer leaktest.AfterTest(t)()
	defer log.Scope(t).Close(t)
	sizeFn := func(e *testElement) int {
		return e.Size()
	}

	element1 := newTestEl(10)
	element2 := newTestEl(10)
	element3 := newTestEl(10)
	tests := []struct {
		name      string
		maxBytes  int
		toEnqueue []*testElement
		expected  *testElement
		// Expected size of queue in bytes after a single Dequeue call
		expByteSize int
		// Expected length after a single Dequeue call
		expLen int
	}{
		{
			name:     "one in, one out",
			maxBytes: 10,
			toEnqueue: []*testElement{
				element1,
			},
			expected:    element1,
			expByteSize: 0,
			expLen:      0,
		},
		{
			name:     "two in, one out",
			maxBytes: 20,
			toEnqueue: []*testElement{
				element1,
				element2,
			},
			expected:    element1,
			expByteSize: 10,
			expLen:      1,
		},
		{
			name:     "three in, max bytes reached, one out",
			maxBytes: 20,
			toEnqueue: []*testElement{
				element1,
				element2,
				element3,
			},
			expected:    element1,
			expByteSize: 10,
			expLen:      1,
		},
		{
			name:        "nothing in, nothing out",
			maxBytes:    20,
			toEnqueue:   []*testElement{},
			expected:    nil,
			expByteSize: 0,
			expLen:      0,
		},
	}
	for _, tc := range tests {
		t.Run(tc.name, func(t *testing.T) {
			q := NewMemoryQueue[*testElement](tc.maxBytes, sizeFn, "enqueue_test")
			for _, el := range tc.toEnqueue {
				// Expected returns of Enqueue are tested separately.
				_ = q.Enqueue(el)
			}
			actual, ok := q.Dequeue()
			require.Equal(t, tc.expected, actual)
			if tc.expected != nil {
				require.True(t, ok)
			} else {
				require.False(t, ok)
			}
			require.Equalf(t, q.Len(), tc.expLen, "unexpected queue length")
			func() {
				q.mu.Lock()
				defer q.mu.Unlock()
				require.Equalf(t, q.mu.curSize, tc.expByteSize, "unexpected size in bytes")
			}()
		})
	}
}