github.com/kardianos/nomad@v0.1.3-0.20151022182107-b13df73ee850/api/constraint_test.go (about)

     1  package api
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestCompose_Constraints(t *testing.T) {
     9  	c := HardConstraint("kernel.name", "=", "darwin")
    10  	expect := &Constraint{
    11  		Hard:    true,
    12  		LTarget: "kernel.name",
    13  		RTarget: "darwin",
    14  		Operand: "=",
    15  		Weight:  0,
    16  	}
    17  	if !reflect.DeepEqual(c, expect) {
    18  		t.Fatalf("expect: %#v, got: %#v", expect, c)
    19  	}
    20  
    21  	c = SoftConstraint("memory.totalbytes", ">=", "250000000", 5)
    22  	expect = &Constraint{
    23  		Hard:    false,
    24  		LTarget: "memory.totalbytes",
    25  		RTarget: "250000000",
    26  		Operand: ">=",
    27  		Weight:  5,
    28  	}
    29  	if !reflect.DeepEqual(c, expect) {
    30  		t.Fatalf("expect: %#v, got: %#v", expect, c)
    31  	}
    32  }