2018-07-20 17:43:22 +00:00
|
|
|
package testing
|
|
|
|
|
|
|
|
import (
|
2018-11-07 18:55:52 +00:00
|
|
|
"testing"
|
|
|
|
|
2018-07-20 17:43:22 +00:00
|
|
|
"github.com/influxdata/platform"
|
|
|
|
)
|
|
|
|
|
2018-12-28 23:02:19 +00:00
|
|
|
// TODO(goller): remove opPrefix argument
|
2018-11-07 18:55:52 +00:00
|
|
|
func diffPlatformErrors(name string, actual, expected error, opPrefix string, t *testing.T) {
|
2018-12-12 18:24:33 +00:00
|
|
|
if expected == nil && actual == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-11-07 18:55:52 +00:00
|
|
|
if expected == nil && actual != nil {
|
2019-01-04 19:12:35 +00:00
|
|
|
t.Errorf("unexpected error %s", actual.Error())
|
2018-11-07 18:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if expected != nil && actual == nil {
|
2019-01-04 19:12:35 +00:00
|
|
|
t.Errorf("expected error %s but received nil", expected.Error())
|
2018-11-07 18:55:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-12 18:24:33 +00:00
|
|
|
if platform.ErrorCode(expected) != platform.ErrorCode(actual) {
|
2019-01-04 19:12:35 +00:00
|
|
|
t.Errorf("expected error code %q but received %q", platform.ErrorCode(expected), platform.ErrorCode(actual))
|
2018-11-07 18:55:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-12 18:24:33 +00:00
|
|
|
if platform.ErrorMessage(expected) != platform.ErrorMessage(actual) {
|
2019-01-04 19:12:35 +00:00
|
|
|
t.Errorf("expected error message %q but received %q", platform.ErrorMessage(expected), platform.ErrorMessage(actual))
|
2018-12-12 18:24:33 +00:00
|
|
|
}
|
2018-11-07 18:55:52 +00:00
|
|
|
}
|
|
|
|
|
2018-10-10 19:39:09 +00:00
|
|
|
// MustIDBase16 is an helper to ensure a correct ID is built during testing.
|
|
|
|
func MustIDBase16(s string) platform.ID {
|
2018-07-20 17:43:22 +00:00
|
|
|
id, err := platform.IDFromString(s)
|
|
|
|
if err != nil {
|
2018-07-20 10:24:07 +00:00
|
|
|
panic(err)
|
2018-07-20 17:43:22 +00:00
|
|
|
}
|
2018-07-30 14:29:52 +00:00
|
|
|
return *id
|
2018-07-20 17:43:22 +00:00
|
|
|
}
|