aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/aws/smithy-go/testing/struct_test.go
diff options
context:
space:
mode:
authorvitalyisaev <vitalyisaev@ydb.tech>2023-12-12 21:55:07 +0300
committervitalyisaev <vitalyisaev@ydb.tech>2023-12-12 22:25:10 +0300
commit4967f99474a4040ba150eb04995de06342252718 (patch)
treec9c118836513a8fab6e9fcfb25be5d404338bca7 /vendor/github.com/aws/smithy-go/testing/struct_test.go
parent2ce9cccb9b0bdd4cd7a3491dc5cbf8687cda51de (diff)
downloadydb-4967f99474a4040ba150eb04995de06342252718.tar.gz
YQ Connector: prepare code base for S3 integration
1. Кодовая база Коннектора переписана с помощью Go дженериков так, чтобы добавление нового источника данных (в частности S3 + csv) максимально переиспользовало имеющийся код (чтобы сохранялась логика нарезания на блоки данных, учёт трафика и пр.) 2. API Connector расширено для работы с S3, но ещё пока не протестировано.
Diffstat (limited to 'vendor/github.com/aws/smithy-go/testing/struct_test.go')
-rw-r--r--vendor/github.com/aws/smithy-go/testing/struct_test.go102
1 files changed, 102 insertions, 0 deletions
diff --git a/vendor/github.com/aws/smithy-go/testing/struct_test.go b/vendor/github.com/aws/smithy-go/testing/struct_test.go
new file mode 100644
index 0000000000..be92c76de2
--- /dev/null
+++ b/vendor/github.com/aws/smithy-go/testing/struct_test.go
@@ -0,0 +1,102 @@
+package testing
+
+import (
+ "bytes"
+ "io"
+ "io/ioutil"
+ "strings"
+ "testing"
+)
+
+func TestCompareStructEqual(t *testing.T) {
+ cases := map[string]struct {
+ A, B interface{}
+ ExpectErr string
+ }{
+ "simple match": {
+ A: struct {
+ Foo string
+ Bar int
+ }{
+ Foo: "abc",
+ Bar: 123,
+ },
+ B: struct {
+ Foo string
+ Bar int
+ }{
+ Foo: "abc",
+ Bar: 123,
+ },
+ },
+ "simple diff": {
+ A: struct {
+ Foo string
+ Bar int
+ }{
+ Foo: "abc",
+ Bar: 123,
+ },
+ B: struct {
+ Foo string
+ Bar int
+ }{
+ Foo: "abc",
+ Bar: 456,
+ },
+ ExpectErr: "values do not match",
+ },
+ "reader match": {
+ A: struct {
+ Foo io.Reader
+ Bar int
+ }{
+ Foo: bytes.NewBuffer([]byte("abc123")),
+ Bar: 123,
+ },
+ B: struct {
+ Foo io.Reader
+ Bar int
+ }{
+ Foo: ioutil.NopCloser(strings.NewReader("abc123")),
+ Bar: 123,
+ },
+ },
+ "reader diff": {
+ A: struct {
+ Foo io.Reader
+ Bar int
+ }{
+ Foo: bytes.NewBuffer([]byte("abc123")),
+ Bar: 123,
+ },
+ B: struct {
+ Foo io.Reader
+ Bar int
+ }{
+ Foo: ioutil.NopCloser(strings.NewReader("123abc")),
+ Bar: 123,
+ },
+ ExpectErr: "bytes do not match",
+ },
+ }
+
+ for name, c := range cases {
+ t.Run(name, func(t *testing.T) {
+ err := CompareValues(c.A, c.B)
+
+ if len(c.ExpectErr) != 0 {
+ if err == nil {
+ t.Fatalf("expect error, got none")
+ }
+ if e, a := c.ExpectErr, err.Error(); !strings.Contains(a, e) {
+ t.Fatalf("expect error to contain %v, got %v", e, a)
+ }
+ return
+ }
+ if err != nil {
+ t.Fatalf("expect no error, got %v", err)
+ }
+ })
+ }
+}