2016-03-23 00:12:30 +00:00
|
|
|
package fingerprint
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/client/config"
|
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
2017-08-16 23:14:59 +00:00
|
|
|
"github.com/hashicorp/nomad/version"
|
2016-03-23 00:12:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNomadFingerprint(t *testing.T) {
|
|
|
|
f := NewNomadFingerprint(testLogger())
|
|
|
|
node := &structs.Node{
|
|
|
|
Attributes: make(map[string]string),
|
|
|
|
}
|
|
|
|
v := "foo"
|
|
|
|
r := "123"
|
|
|
|
c := &config.Config{
|
2017-08-16 23:14:59 +00:00
|
|
|
Version: &version.VersionInfo{
|
|
|
|
Revision: r,
|
|
|
|
Version: v,
|
|
|
|
},
|
2016-03-23 00:12:30 +00:00
|
|
|
}
|
|
|
|
ok, err := f.Fingerprint(c, node)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if !ok {
|
|
|
|
t.Fatalf("should apply")
|
|
|
|
}
|
|
|
|
if node.Attributes["nomad.version"] != v {
|
|
|
|
t.Fatalf("incorrect version")
|
|
|
|
}
|
|
|
|
if node.Attributes["nomad.revision"] != r {
|
|
|
|
t.Fatalf("incorrect revision")
|
|
|
|
}
|
|
|
|
}
|