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

Commit 7a8a336

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 1f9b3f9 commit 7a8a336

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

functional/systemd_test.go

+12-1
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)