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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor generator validation #15
Refactor generator validation #15
Conversation
This commit reverts the changes made in #10 and places the generator validation inside the NewColumns function. This function iterates and "parses" all keys so we do not need to re-implement all parsing. Tests have been adjusted so that they can handle expected error cases.
@KevinGimbel this looks great! One small detail: we changed the test assertion to I'm thinking maybe we should extract I can take care of it if you don't have the time. The code looks pretty good already as it is. Thank you very much! |
Thanks for the kind words!
That makes sense. Handling both cases would mean changing all Column tests to something like this? t.Run(tt.name, func(t *testing.T) {
actual, err := fakedata.NewColumns(tt.input)
// Test fails with unexpected result
if !reflect.DeepEqual(actual, tt.expected) {
t.Errorf("NewColumns() = %v, want %v", actual, tt.expected)
}
// Dont't want error but got error
if (err != nil) && !tt.wantErr {
t.Errorf("NewColumns() = Dont want error but got: %v", err)
}
}) Printing the "expected" errors from I can make the changes in my lunch break today. :) |
@KevinGimbel that looks perfect to me! |
@lucapette yay! 馃帀 I'll implemented it later today then. |
I made the changes to all tests in if !reflect.DeepEqual(actual, tt.expected) && !tt.wantErr {
t.Errorf("NewColumns() = %v, want %v", actual, tt.expected)
} For tests that should fail we need the check for --- FAIL: TestNewColumns/two_columns,_one_column_fails (0.00s)
column_test.go:28: NewColumns() = [{email email } {domain domain } {unsupportedgenerator unsupportedgenerator }], want []
--- FAIL: TestNewColumns/one_column,_all_fails (0.00s)
column_test.go:28: NewColumns() = [{madeupgenerator madeupgenerator }], want [] These two tests are defined with |
@KevinGimbel so cool! thank you again! |
@lucapette you're welcome! It's been fun to work on some "real" Go code. :D if you ever want some more help hit me up. |
@KevinGimbel I have a small list of generators and some little gardening I'd like to do. I'll be opening issues in the coming days. If you'd like to take over one of the issues, I'd very grateful and happy to help! |
@lucapette I'll keep an eye on issues and will let you know when I have the time to work on one or more. It's a good exercise for me, both in Go and general GitHub workflow/contributing to other people's code. Thank you again for being so welcoming! |
This patch reverts the changes made in #10 and places the generator
validation inside the
NewColumns
function.Tests have been adjusted so that they can handle expected error cases for unknown generators.
I manually tested it and ran the tests locally with
make test
and I believe this time nothing is broken! 馃槃