github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/scheduler/reconcile_util_test.go (about)

     1  package scheduler
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/nomad/nomad/structs"
     7  )
     8  
     9  // Test that we properly create the bitmap even when the alloc set includes an
    10  // allocation with a higher count than the current min count and it is byte
    11  // aligned.
    12  // Ensure no regerssion from: https://github.com/hashicorp/nomad/issues/3008
    13  func TestBitmapFrom(t *testing.T) {
    14  	input := map[string]*structs.Allocation{
    15  		"8": {
    16  			JobID:     "foo",
    17  			TaskGroup: "bar",
    18  			Name:      "foo.bar[8]",
    19  		},
    20  	}
    21  	b := bitmapFrom(input, 1)
    22  	exp := uint(16)
    23  	if act := b.Size(); act != exp {
    24  		t.Fatalf("got %d; want %d", act, exp)
    25  	}
    26  
    27  	b = bitmapFrom(input, 8)
    28  	if act := b.Size(); act != exp {
    29  		t.Fatalf("got %d; want %d", act, exp)
    30  	}
    31  }