tests over setwise equality of fingerprinted parts

This commit is contained in:
Lang Martin 2019-04-19 15:49:24 -04:00
parent 7de6e28ddc
commit 8aa97cff13

View file

@ -617,6 +617,62 @@ func TestJob_RequiredSignals(t *testing.T) {
}
}
// test new Equal comparisons for components of Jobs
func TestJob_PartEqual(t *testing.T) {
ns := &Networks{}
if !ns.Equals(&Networks{}) {
t.Fatal("network set wise not equal")
}
ns = &Networks{
&NetworkResource{Device: "eth0"},
}
if !ns.Equals(&Networks{
&NetworkResource{Device: "eth0"},
}) {
t.Fatal("network set wise not equal")
}
ns = &Networks{
&NetworkResource{Device: "eth0"},
&NetworkResource{Device: "eth1"},
&NetworkResource{Device: "eth2"},
}
if !ns.Equals(&Networks{
&NetworkResource{Device: "eth2"},
&NetworkResource{Device: "eth0"},
&NetworkResource{Device: "eth1"},
}) {
t.Fatal("network set wise not equal")
}
cs := &Constraints{
&Constraint{"left0", "right0", "=", ""},
&Constraint{"left1", "right1", "=", ""},
&Constraint{"left2", "right2", "=", ""},
}
if !cs.Equals(&Constraints{
&Constraint{"left0", "right0", "=", ""},
&Constraint{"left2", "right2", "=", ""},
&Constraint{"left1", "right1", "=", ""},
}) {
t.Fatal("constraint set wise not equal")
}
as := &Affinities{
&Affinity{"left0", "right0", "=", 0, ""},
&Affinity{"left1", "right1", "=", 0, ""},
&Affinity{"left2", "right2", "=", 0, ""},
}
if !as.Equals(&Affinities{
&Affinity{"left0", "right0", "=", 0, ""},
&Affinity{"left2", "right2", "=", 0, ""},
&Affinity{"left1", "right1", "=", 0, ""},
}) {
t.Fatal("affinity set wise not equal")
}
}
func TestTaskGroup_Validate(t *testing.T) {
j := testJob()
tg := &TaskGroup{