states: In Module.testString, use incrementing ids for deposed
In our old world we always used 1-based indices into a slice of deposed objects. The new models instead use a map keyed by pseudorandom strings, so that deposed objects will have a consistent identity across multiple operations. However, having that pseudo-random string in our test comparison output is not helpful, since such strings can never match hard-coded expectation strings. Therefore for the purposes of generating this test comparison output we'll revert back to using 1-based indexes. This should avoid problems for tests that only create one deposed object per instance, but those which create more than one will need to do some more work since the _ordering_ of these objects in the output is still pseudorandom as a result of it coming from a map rather than a slice.
This commit is contained in:
parent
425d5cd191
commit
d48f3600fe
|
@ -182,13 +182,15 @@ func (m *Module) testString() string {
|
|||
// CAUTION: Since deposed keys are now random strings instead of
|
||||
// incrementing integers, this result will not be deterministic
|
||||
// if there is more than one deposed object.
|
||||
for k, t := range is.Deposed {
|
||||
i := 1
|
||||
for _, t := range is.Deposed {
|
||||
id := legacyInstanceObjectID(t)
|
||||
taintStr := ""
|
||||
if t.Status == ObjectTainted {
|
||||
taintStr = " (tainted)"
|
||||
}
|
||||
buf.WriteString(fmt.Sprintf(" Deposed ID %s = %s%s\n", k, id, taintStr))
|
||||
buf.WriteString(fmt.Sprintf(" Deposed ID %d = %s%s\n", i, id, taintStr))
|
||||
i++
|
||||
}
|
||||
|
||||
if obj := is.Current; obj != nil && len(obj.Dependencies) > 0 {
|
||||
|
|
Loading…
Reference in New Issue