Open jerry871002 opened 2 months ago
I tried to test the endpoint with invalid data, but it still returned valid results.
The first batter contains an invalid field and a typo:
curl -X POST http://localhost:8080/simulate -H "Content-Type: application/json" -d '[ {"name": "Jerry", "at_bat": 30, "hit": 6, "double": 2, "triple": 1, "walk": 4, "hitt_by_pitch": 1, "invalid": 10}, {"name": "Tom", "at_bat": 25, "hit": 6, "double": 1, "triple": 0, "home_run": 2, "walk": 3, "hit_by_pitch": 0}, {"name": "Spike", "at_bat": 28, "hit": 9, "double": 3, "triple": 0, "home_run": 1, "walk": 2, "hit_by_pitch": 1}, {"name": "Tyke", "at_bat": 27, "hit": 7, "double": 2, "triple": 1, "home_run": 0, "walk": 5, "hit_by_pitch": 0}, {"name": "Butch", "at_bat": 29, "hit": 9, "double": 1, "triple": 1, "home_run": 1, "walk": 3, "hit_by_pitch": 1}, {"name": "Nibbles", "at_bat": 26, "hit": 8, "double": 2, "triple": 0, "home_run": 1, "walk": 4, "hit_by_pitch": 0}, {"name": "Lightning", "at_bat": 24, "hit": 7, "double": 1, "triple": 1, "home_run": 2, "walk": 2, "hit_by_pitch": 1}, {"name": "Tuffy", "at_bat": 31, "hit": 10, "double": 2, "triple": 0, "home_run": 3, "walk": 3, "hit_by_pitch": 1}, {"name": "Quacker", "at_bat": 30, "hit": 9, "double": 1, "triple": 1, "home_run": 1, "walk": 4, "hit_by_pitch": 1} ]'
Maybe I should also add a test to make sure this is checked automatically.
I think it's because Go variables have default values and that's why there's no error. Maybe I need to add some validation when receiving the json data.
I tried to test the endpoint with invalid data, but it still returned valid results.
The first batter contains an invalid field and a typo:
Maybe I should also add a test to make sure this is checked automatically.