github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/client/fingerprint/memory_test.go (about)

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