googleinterns / cloud-operations-api-mock

Apache License 2.0
5 stars 2 forks source link

Cleanup errors: try not to export all the statuses, replace string comparison error handling #22

Closed mabdi3 closed 4 years ago

mabdi3 commented 4 years ago

Currently to verify errors in our tests, we use string comparison which is very brittle. Looking to implement an alternative solution to provide similar functionality. Here's an example of where we use string comparisons in mock_metric_test.go:

if !strings.Contains(err.Error(), want.Error()) {
        t.Errorf("CreateMetricDescriptor(%q) returned error %q, expected error %q",
            in, err.Error(), want)
    }

We should switch to just comparing the codes, instead of the error strings themselves