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: operation_test.go
    path of file: ./repos/kubernetes/pkg/registry/core/service/portallocator
    
    the code of the file until where you have to start completion: /*
Copyright 2018 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the Li
    
func TestDryRunAllocateNext(t *testing.T) {
	pr, err := net.ParsePortRange("10000-10200")
	if err != nil {
		t.Fatal(err)
	}

	// Allocate some ports before calling
	previouslyAllocated := []int{10000, 10010, 10020}
	r, err := NewInMemory(*pr)
	if err != nil {
		t.Fatal(err)
	}
	for _, port := range previouslyAllocated {
		_ = r.Allocate(port)
	}
	freeAtStart := r.Free()

	// AllocateNext without a previously unused dry run operation
	op := StartOperation(r, true)
	port, err := op.AllocateNext()
	if port == 0 {
		t.Errorf("expected non zero port but got: %v", port)
	}
	if err != nil {
		t.Errorf("expected no error but got: %v", err)
	}

	// Try to allocate the returned port using the same operation
	if e, a := ErrAllocated, op.Allocate(port); e != a {
		t.Errorf("expected %v but got: %v", e, a)
	}

	// AllocateNext with a previously used dry run operation
	op = StartOperation(r, true)
	_ = op.Allocate(12345)
	port, err = op.AllocateNext()
	if port == 0 {
		t.Errorf("expected non zero port but got: %v", port)
	}
	if port == 12345 {
		t.Errorf("expected port not to be 12345 but got %v", port)
	}
	if err != nil {
		t.Errorf("expected no error but got: %v", err)
	}

	// Make sure no port allocations were actually made by the dry run
	freeAtEnd := r.Free()
	if freeAtStart != freeAtEnd {
		t.Errorf("expected %v free ports but got %v", freeAtStart, freeAtEnd)
	}
}