github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/client/fingerprint/host_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 TestHostFingerprint(t *testing.T) { 13 ci.Parallel(t) 14 15 f := NewHostFingerprint(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 if len(response.Attributes) == 0 { 32 t.Fatalf("should generate a diff of node attributes") 33 } 34 35 // Host info 36 for _, key := range []string{"os.name", "os.version", "unique.hostname", "kernel.name"} { 37 assertNodeAttributeContains(t, response.Attributes, key) 38 } 39 }