-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test case to gitparse that previously caused a panic #1571
base: main
Are you sure you want to change the base?
Conversation
Tested and the #1570 fix handles this. It looked to me like it shouldn't miss anything at first glance. If |
//go:embed testdata/panic_diff_1.txt | ||
panicDiff1 []byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I didn't know you could do this!
// setup logger | ||
logger, sync := log.New("forager/scanner", | ||
log.WithConsoleSink(os.Stderr), | ||
) | ||
defer func() { _ = sync() }() | ||
context.SetDefaultLogger(logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log setup can probably be removed - we now have a default global logger that will be used from context.Background()
.
ctx := context.Background() | ||
parser := NewParser() | ||
commitCh := make(chan Commit, 64) | ||
parser.FromReader(ctx, io.NopCloser(bytes.NewReader(panicDiff1)), commitCh, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the idea of this test that this line won't panic? What do you think about using assert.NotPanics to make that explicit?
Adds a test case to gitparse that caused a panic which was fixed by #1570