github.com/hashicorp/nomad/api@v0.0.0-20240306165712-3193ac204f65/internal/testutil/ports.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package testutil
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/shoenig/test/portal"
    10  )
    11  
    12  type fatalTester struct{}
    13  
    14  func (t *fatalTester) Fatalf(msg string, args ...any) {
    15  	panic(fmt.Sprintf(msg, args...))
    16  }
    17  
    18  // PortAllocator is used to acquire unused ports for testing real network
    19  // listeners.
    20  var PortAllocator = portal.New(
    21  	new(fatalTester),
    22  	portal.WithAddress("127.0.0.1"),
    23  )