aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/aws/smithy-go/encoding/xml/map_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/encoding/xml/map_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/encoding/xml/map_test.go')
-rw-r--r--vendor/github.com/aws/smithy-go/encoding/xml/map_test.go77
1 files changed, 77 insertions, 0 deletions
diff --git a/vendor/github.com/aws/smithy-go/encoding/xml/map_test.go b/vendor/github.com/aws/smithy-go/encoding/xml/map_test.go
new file mode 100644
index 0000000000..022165bd6d
--- /dev/null
+++ b/vendor/github.com/aws/smithy-go/encoding/xml/map_test.go
@@ -0,0 +1,77 @@
+package xml
+
+import (
+ "bytes"
+ "testing"
+)
+
+func TestWrappedMap(t *testing.T) {
+ buffer := bytes.NewBuffer(nil)
+ scratch := make([]byte, 64)
+
+ func() {
+ m := newMap(buffer, &scratch)
+
+ key := StartElement{Name: Name{Local: "key"}}
+ value := StartElement{Name: Name{Local: "value"}}
+
+ // map entry
+ e := m.Entry()
+ e.MemberElement(key).String("example-key1")
+ e.MemberElement(value).String("example1")
+ e.Close()
+
+ // map entry
+ e = m.Entry()
+ e.MemberElement(key).String("example-key2")
+ e.MemberElement(value).String("example2")
+ e.Close()
+
+ // map entry
+ e = m.Entry()
+ e.MemberElement(key).String("example-key3")
+ e.MemberElement(value).String("example3")
+ e.Close()
+ }()
+
+ ex := []byte(`<entry><key>example-key1</key><value>example1</value></entry><entry><key>example-key2</key><value>example2</value></entry><entry><key>example-key3</key><value>example3</value></entry>`)
+ if a := buffer.Bytes(); bytes.Compare(ex, a) != 0 {
+ t.Errorf("expected %+q, but got %+q", ex, a)
+ }
+}
+
+func TestFlattenedMapWithCustomName(t *testing.T) {
+ buffer := bytes.NewBuffer(nil)
+ scratch := make([]byte, 64)
+
+ func() {
+ root := StartElement{Name: Name{Local: "flatMap"}}
+ m := newFlattenedMap(buffer, &scratch, root)
+
+ key := StartElement{Name: Name{Local: "key"}}
+ value := StartElement{Name: Name{Local: "value"}}
+
+ // map entry
+ e := m.Entry()
+ e.MemberElement(key).String("example-key1")
+ e.MemberElement(value).String("example1")
+ e.Close()
+
+ // map entry
+ e = m.Entry()
+ e.MemberElement(key).String("example-key2")
+ e.MemberElement(value).String("example2")
+ e.Close()
+
+ // map entry
+ e = m.Entry()
+ e.MemberElement(key).String("example-key3")
+ e.MemberElement(value).String("example3")
+ e.Close()
+ }()
+
+ ex := []byte(`<flatMap><key>example-key1</key><value>example1</value></flatMap><flatMap><key>example-key2</key><value>example2</value></flatMap><flatMap><key>example-key3</key><value>example3</value></flatMap>`)
+ if a := buffer.Bytes(); bytes.Compare(ex, a) != 0 {
+ t.Errorf("expected %+q, but got %+q", ex, a)
+ }
+}