github.com/bigcommerce/nomad@v0.9.3-bc/client/fingerprint/host_test.go (about)

     1  package fingerprint
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/nomad/client/config"
     7  	"github.com/hashicorp/nomad/helper/testlog"
     8  	"github.com/hashicorp/nomad/nomad/structs"
     9  )
    10  
    11  func TestHostFingerprint(t *testing.T) {
    12  	f := NewHostFingerprint(testlog.HCLogger(t))
    13  	node := &structs.Node{
    14  		Attributes: make(map[string]string),
    15  	}
    16  
    17  	request := &FingerprintRequest{Config: &config.Config{}, Node: node}
    18  	var response FingerprintResponse
    19  	err := f.Fingerprint(request, &response)
    20  	if err != nil {
    21  		t.Fatalf("err: %v", err)
    22  	}
    23  
    24  	if !response.Detected {
    25  		t.Fatalf("expected response to be applicable")
    26  	}
    27  
    28  	if len(response.Attributes) == 0 {
    29  		t.Fatalf("should generate a diff of node attributes")
    30  	}
    31  
    32  	// Host info
    33  	for _, key := range []string{"os.name", "os.version", "unique.hostname", "kernel.name"} {
    34  		assertNodeAttributeContains(t, response.Attributes, key)
    35  	}
    36  }