github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/client/fingerprint/arch_test.go (about)

     1  package fingerprint
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/nomad/ci"
     7  	"github.com/hashicorp/nomad/client/config"
     8  	"github.com/hashicorp/nomad/helper/testlog"
     9  	"github.com/hashicorp/nomad/nomad/structs"
    10  )
    11  
    12  func TestArchFingerprint(t *testing.T) {
    13  	ci.Parallel(t)
    14  
    15  	f := NewArchFingerprint(testlog.HCLogger(t))
    16  	node := &structs.Node{
    17  		Attributes: make(map[string]string),
    18  	}
    19  
    20  	request := &FingerprintRequest{Config: &config.Config{}, Node: node}
    21  	var response FingerprintResponse
    22  	err := f.Fingerprint(request, &response)
    23  	if err != nil {
    24  		t.Fatalf("err: %v", err)
    25  	}
    26  
    27  	if !response.Detected {
    28  		t.Fatalf("expected response to be applicable")
    29  	}
    30  
    31  	assertNodeAttributeContains(t, response.Attributes, "cpu.arch")
    32  }