github.com/kardianos/nomad@v0.1.3-0.20151022182107-b13df73ee850/client/fingerprint/storage_test.go (about) 1 package fingerprint 2 3 import ( 4 "strconv" 5 "testing" 6 7 "github.com/hashicorp/nomad/nomad/structs" 8 ) 9 10 func TestStorageFingerprint(t *testing.T) { 11 fp := NewStorageFingerprint(testLogger()) 12 node := &structs.Node{ 13 Attributes: make(map[string]string), 14 } 15 16 assertFingerprintOK(t, fp, node) 17 18 assertNodeAttributeContains(t, node, "storage.volume") 19 assertNodeAttributeContains(t, node, "storage.bytestotal") 20 assertNodeAttributeContains(t, node, "storage.bytesfree") 21 22 total, err := strconv.ParseInt(node.Attributes["storage.bytestotal"], 10, 64) 23 if err != nil { 24 t.Fatalf("Failed to parse storage.bytestotal: %s", err) 25 } 26 free, err := strconv.ParseInt(node.Attributes["storage.bytesfree"], 10, 64) 27 if err != nil { 28 t.Fatalf("Failed to parse storage.bytesfree: %s", err) 29 } 30 31 if free > total { 32 t.Errorf("storage.bytesfree %d is larger than storage.bytestotal %d", free, total) 33 } 34 35 if node.Resources.DiskMB == 0 { 36 t.Errorf("Expected node.Resources.DiskMB to be non-zero") 37 } 38 }