github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/client/fingerprint/memory_test.go (about)

     1  package fingerprint
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/nomad/client/config"
     7  	"github.com/hashicorp/nomad/nomad/structs"
     8  )
     9  
    10  func TestMemoryFingerprint(t *testing.T) {
    11  	f := NewMemoryFingerprint(testLogger())
    12  	node := &structs.Node{
    13  		Attributes: make(map[string]string),
    14  	}
    15  	ok, err := f.Fingerprint(&config.Config{}, node)
    16  	if err != nil {
    17  		t.Fatalf("err: %v", err)
    18  	}
    19  	if !ok {
    20  		t.Fatalf("should apply")
    21  	}
    22  
    23  	assertNodeAttributeContains(t, node, "memory.totalbytes")
    24  
    25  	if node.Resources == nil {
    26  		t.Fatalf("Node Resources was nil")
    27  	}
    28  	if node.Resources.MemoryMB == 0 {
    29  		t.Errorf("Expected node.Resources.MemoryMB to be non-zero")
    30  	}
    31  
    32  }