Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 63a3b28

Browse files
author
Dongsu Park
committed
functional: exclude ActiveEnterTimestamp from unit comparison condition
Actually it's not necessary to check that both units have the same value for ActiveEnterTimestamp, as it can vary at any time. So let's exclude ActiveEnterTimestamp from the condition for unit comparison.
1 parent f73c0bd commit 63a3b28

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

functional/systemd_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,19 @@ func waitForUnitState(mgr unit.UnitManager, name string, want unit.UnitState) er
119119
return err
120120
}
121121

122-
if reflect.DeepEqual(want, *got) {
122+
if isEqualUnitState(want, *got) {
123123
return nil
124124
}
125125
}
126126
}
127+
128+
// isEqualUnitState checks if both units are the same,
129+
// excluding ActiveEnterTimestamp field of each unit state.
130+
func isEqualUnitState(src, dst unit.UnitState) bool {
131+
return src.LoadState == dst.LoadState &&
132+
src.ActiveState == dst.ActiveState &&
133+
src.SubState == dst.SubState &&
134+
src.MachineID == dst.MachineID &&
135+
src.UnitHash == dst.UnitHash &&
136+
src.UnitName == dst.UnitName
137+
}

0 commit comments

Comments
 (0)