github.com/zhizhiboom/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/client/fingerprint/arch_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/helper/testlog"
     9  	"github.com/hashicorp/nomad/nomad/structs"
    10  )
    11  
    12  func TestArchFingerprint(t *testing.T) {
    13  	f := NewArchFingerprint(testlog.Logger(t))
    14  	node := &structs.Node{
    15  		Attributes: make(map[string]string),
    16  	}
    17  
    18  	request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
    19  	var response cstructs.FingerprintResponse
    20  	err := f.Fingerprint(request, &response)
    21  	if err != nil {
    22  		t.Fatalf("err: %v", err)
    23  	}
    24  
    25  	if !response.Detected {
    26  		t.Fatalf("expected response to be applicable")
    27  	}
    28  
    29  	assertNodeAttributeContains(t, response.Attributes, "cpu.arch")
    30  }