renamed step/undoStep -> push/pop

This commit is contained in:
Shreyas Goenka 2023-01-20 16:26:13 +01:00
parent 9599e63ffb
commit 6be09cfdb6
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
3 changed files with 7 additions and 7 deletions

View File

@ -130,12 +130,12 @@ func safeToSchema(golangType reflect.Type, docs *Docs, traceId string, tracker *
return nil, fmt.Errorf("cycle detected")
}
tracker.step(golangType, traceId)
tracker.push(golangType, traceId)
props, err := toSchema(golangType, docs, tracker)
if err != nil {
return nil, err
}
tracker.undoStep(golangType)
tracker.pop(golangType)
return props, nil
}

View File

@ -665,12 +665,12 @@ func TestErrorWithTrace(t *testing.T) {
err := tracker.errWithTrace("with empty trace")
assert.ErrorContains(t, err, "[ERROR] with empty trace. traversal trace: root")
tracker.step(dummyType, "resources")
tracker.push(dummyType, "resources")
err = tracker.errWithTrace("with depth = 1")
assert.ErrorContains(t, err, "[ERROR] with depth = 1. traversal trace: root -> resources")
tracker.step(dummyType, "pipelines")
tracker.step(dummyType, "datasets")
tracker.push(dummyType, "pipelines")
tracker.push(dummyType, "datasets")
err = tracker.errWithTrace("with depth = 4")
assert.ErrorContains(t, err, "[ERROR] with depth = 4. traversal trace: root -> resources -> pipelines -> datasets")
}

View File

@ -45,12 +45,12 @@ func (t *tracker) hasCycle(golangType reflect.Type) bool {
return ok
}
func (t *tracker) step(nodeType reflect.Type, jsonName string) {
func (t *tracker) push(nodeType reflect.Type, jsonName string) {
t.seenTypes[nodeType] = struct{}{}
t.debugTrace.PushBack(jsonName)
}
func (t *tracker) undoStep(nodeType reflect.Type) {
func (t *tracker) pop(nodeType reflect.Type) {
back := t.debugTrace.Back()
t.debugTrace.Remove(back)
delete(t.seenTypes, nodeType)