1/*
2Copyright 2018 Google LLC
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package spanner
18
19import (
20	"math/big"
21	"strings"
22
23	"cloud.google.com/go/internal/testutil"
24	"github.com/google/go-cmp/cmp"
25)
26
27// TODO(deklerk): move this to internal/testutil
28func testEqual(a, b interface{}) bool {
29	return testutil.Equal(a, b,
30		cmp.AllowUnexported(TimestampBound{}, Error{}, TransactionOutcomeUnknownError{},
31			Mutation{}, Row{}, Partition{}, BatchReadOnlyTransactionID{}, big.Rat{}, big.Int{}),
32		cmp.FilterPath(func(path cmp.Path) bool {
33			// Ignore Error.state, Error.sizeCache, and Error.unknownFields
34			if strings.HasSuffix(path.GoString(), ".err.(*status.Error).state") {
35				return true
36			}
37			if strings.HasSuffix(path.GoString(), ".err.(*status.Error).sizeCache") {
38				return true
39			}
40			if strings.HasSuffix(path.GoString(), ".err.(*status.Error).unknownFields") {
41				return true
42			}
43			if strings.HasSuffix(path.GoString(), ".err.(*status.Error).e") {
44				return true
45			}
46			if strings.Contains(path.GoString(), "{*status.Error}.state") {
47				return true
48			}
49			if strings.Contains(path.GoString(), "{*status.Error}.sizeCache") {
50				return true
51			}
52			if strings.Contains(path.GoString(), "{*status.Error}.unknownFields") {
53				return true
54			}
55			if strings.Contains(path.GoString(), "{*status.Error}.e") {
56				return true
57			}
58			return false
59		}, cmp.Ignore()))
60}
61