23 lines
1.3 KiB
Go
23 lines
1.3 KiB
Go
package bucket
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestListUnmarshal(t *testing.T) {
|
|
xml := []byte(`
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>screenshot</Name><Prefix></Prefix><Marker></Marker><MaxKeys>10000</MaxKeys><Delimiter></Delimiter><IsTruncated>false</IsTruncated><Contents><Key>Screenshot_2020-08-02 [Filebeat Cisco] ASA Firewall - Elastic.png</Key><LastModified>2020-08-22T13:44:33.034Z</LastModified><ETag>"94aef50ebfceadd0cefee92b14b7e73a"</ETag><Size>190116</Size><Owner><ID>02d6176db174dc93cb1b899f7c6078f08654445fe8cf1b6ce98d8855f66bdbf4</ID><DisplayName></DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>grim.png</Key><LastModified>2020-08-20T06:37:30.595Z</LastModified><ETag>"7078589d69baa9434ab28729449ed7a9"</ETag><Size>5166601</Size><Owner><ID>02d6176db174dc93cb1b899f7c6078f08654445fe8cf1b6ce98d8855f66bdbf4</ID><DisplayName></DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents></ListBucketResult>
|
|
`)
|
|
l, err := ListUnmarshal(xml)
|
|
if err != nil {
|
|
t.Errorf("%v", err)
|
|
}
|
|
if string(l[0]) != "Screenshot_2020-08-02 [Filebeat Cisco] ASA Firewall - Elastic.png" {
|
|
t.Errorf("Wrong filename")
|
|
}
|
|
if string(l[1]) != "grim.png" {
|
|
t.Errorf("Wrong filename")
|
|
}
|
|
}
|