From 841126530f9e219c8da3cfda262c620ea85e1356 Mon Sep 17 00:00:00 2001 From: Mariana Cardoso Date: Fri, 21 Apr 2017 14:35:34 -0700 Subject: [PATCH] Get entity and table without using query funcs (#48) * Complete parameters for table operations * Complete parameters in entity operations * Complete parameters in query table operation * Added get entity operation * Added get table operation * Included test recordings * Fixed merge little mess * Fix travis --- storage/entity.go | 77 +++++- storage/entity_test.go | 46 ++++ .../StorageEntitySuite/TestGet.yaml | 253 ++++++++++++++++++ .../recordings/StorageTableSuite/TestGet.yaml | 126 +++++++++ storage/table.go | 41 ++- storage/table_test.go | 20 ++ storage/tableserviceclient.go | 1 - 7 files changed, 554 insertions(+), 10 deletions(-) create mode 100644 storage/recordings/StorageEntitySuite/TestGet.yaml create mode 100644 storage/recordings/StorageTableSuite/TestGet.yaml diff --git a/storage/entity.go b/storage/entity.go index 86dd995ad8c7..29e73ed4ce38 100644 --- a/storage/entity.go +++ b/storage/entity.go @@ -59,6 +59,64 @@ type EntityOptions struct { RequestID string `header:"x-ms-client-request-id"` } +// GetEntityOptions includes options for a get entity operation +type GetEntityOptions struct { + Select []string + RequestID string `header:"x-ms-client-request-id"` +} + +// Get gets the referenced entity. Which properties to get can be +// specified using the select option. +// See: +// https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/query-entities +// https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/querying-tables-and-entities +func (e *Entity) Get(timeout uint, ml MetadataLevel, options *GetEntityOptions) error { + if ml == EmptyPayload { + return errEmptyPayload + } + // RowKey and PartitionKey could be lost if not included in the query + // As those are the entity identifiers, it is best if they are not lost + rk := e.RowKey + pk := e.PartitionKey + + query := url.Values{ + "timeout": {strconv.FormatUint(uint64(timeout), 10)}, + } + headers := e.Table.tsc.client.getStandardHeaders() + headers[headerAccept] = string(ml) + + if options != nil { + if len(options.Select) > 0 { + query.Add("$select", strings.Join(options.Select, ",")) + } + headers = mergeHeaders(headers, headersFromStruct(*options)) + } + + uri := e.Table.tsc.client.getEndpoint(tableServiceName, e.buildPath(), query) + resp, err := e.Table.tsc.client.exec(http.MethodGet, uri, headers, nil, e.Table.tsc.auth) + if err != nil { + return err + } + defer readAndCloseBody(resp.body) + + if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return err + } + + respBody, err := ioutil.ReadAll(resp.body) + if err != nil { + return err + } + err = json.Unmarshal(respBody, e) + if err != nil { + return err + } + e.PartitionKey = pk + e.RowKey = rk + + return nil +} + // Insert inserts the referenced entity in its table. // The function fails if there is an entity with the same // PartitionKey and RowKey in the table. @@ -224,15 +282,18 @@ func (e *Entity) UnmarshalJSON(data []byte) error { e.RowKey = stringFromMap(props, rowKeyNode) // deserialize timestamp - str, ok := props["Timestamp"].(string) - if !ok { - return fmt.Errorf(errorTemplate, "Timestamp casting error") - } - t, err := time.Parse(time.RFC3339Nano, str) - if err != nil { - return fmt.Errorf(errorTemplate, err) + timeStamp, ok := props["Timestamp"] + if ok { + str, ok := timeStamp.(string) + if !ok { + return fmt.Errorf(errorTemplate, "Timestamp casting error") + } + t, err := time.Parse(time.RFC3339Nano, str) + if err != nil { + return fmt.Errorf(errorTemplate, err) + } + e.TimeStamp = t } - e.TimeStamp = t delete(props, "Timestamp") delete(props, "Timestamp@odata.type") diff --git a/storage/entity_test.go b/storage/entity_test.go index 488fb639d6dc..4d194111b18d 100644 --- a/storage/entity_test.go +++ b/storage/entity_test.go @@ -13,6 +13,52 @@ type StorageEntitySuite struct{} var _ = chk.Suite(&StorageEntitySuite{}) +func (s *StorageEntitySuite) TestGet(c *chk.C) { + cli := getTableClient(c) + rec := cli.client.appendRecorder(c) + defer rec.Stop() + + table := cli.GetTableReference(tableName(c)) + + err := table.Create(30, EmptyPayload, nil) + c.Assert(err, chk.IsNil) + defer table.Delete(30, nil) + + entity := table.GetEntityReference("mypartitionkey", "myrowkey") + + props := map[string]interface{}{ + "AmountDue": 200.23, + "CustomerCode": uuid.FromStringOrNil("c9da6455-213d-42c9-9a79-3e9149a57833"), + "CustomerSince": time.Date(1992, time.December, 20, 21, 55, 0, 0, time.UTC), + "IsActive": true, + "NumberOfOrders": int64(255), + } + entity.Properties = props + err = entity.Insert(EmptyPayload, nil) + c.Assert(err, chk.IsNil) + + err = entity.Get(30, FullMetadata, &GetEntityOptions{ + Select: []string{"IsActive"}, + }) + c.Assert(err, chk.IsNil) + c.Assert(entity.Properties, chk.HasLen, 1) + + err = entity.Get(30, FullMetadata, &GetEntityOptions{ + Select: []string{ + "AmountDue", + "CustomerCode", + "CustomerSince", + "IsActive", + "NumberOfOrders", + }}) + c.Assert(err, chk.IsNil) + c.Assert(entity.Properties, chk.HasLen, 5) + + err = entity.Get(30, FullMetadata, nil) + c.Assert(err, chk.IsNil) + c.Assert(entity.Properties, chk.HasLen, 5) +} + const ( validEtag = "W/\"datetime''2017-04-01T01%3A07%3A23.8881885Z''\"" ) diff --git a/storage/recordings/StorageEntitySuite/TestGet.yaml b/storage/recordings/StorageEntitySuite/TestGet.yaml new file mode 100644 index 000000000000..a20ab5b67b13 --- /dev/null +++ b/storage/recordings/StorageEntitySuite/TestGet.yaml @@ -0,0 +1,253 @@ +--- +version: 1 +rwmutex: {} +interactions: +- request: + body: | + {"TableName":"table26storageentitysuitetestget"} + form: {} + headers: + Accept: + - application/json;odata=nometadata + Accept-Charset: + - UTF-8 + Authorization: + - SharedKey golangrocksonazure:WSKjrlxzsHVqJxVBAM3GHKdqJuaffs6+cjliU1X7+rc= + Content-Length: + - "49" + Content-Type: + - application/json + Prefer: + - return-no-content + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 table + X-Ms-Date: + - Fri, 21 Apr 2017 19:01:28 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.table.core.windows.net/Tables?timeout=30 + method: POST + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Dataserviceid: + - https://golangrocksonazure.table.core.windows.net/Tables('table26storageentitysuitetestget') + Date: + - Fri, 21 Apr 2017 19:01:29 GMT + Location: + - https://golangrocksonazure.table.core.windows.net/Tables('table26storageentitysuitetestget') + Preference-Applied: + - return-no-content + Server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + X-Content-Type-Options: + - nosniff + X-Ms-Request-Id: + - 01dca395-0002-0077-53d1-ba87f8000000 + X-Ms-Version: + - 2016-05-31 + status: 204 No Content + code: 204 +- request: + body: '{"AmountDue":200.23,"CustomerCode":"c9da6455-213d-42c9-9a79-3e9149a57833","CustomerCode@odata.type":"Edm.Guid","CustomerSince":"1992-12-20T21:55:00Z","CustomerSince@odata.type":"Edm.DateTime","IsActive":true,"NumberOfOrders":"255","NumberOfOrders@odata.type":"Edm.Int64","PartitionKey":"mypartitionkey","RowKey":"myrowkey"}' + form: {} + headers: + Accept: + - application/json;odata=nometadata + Accept-Charset: + - UTF-8 + Authorization: + - SharedKey golangrocksonazure:wcHFp+gr7ZpvZFiASYHDhBYHrlGYf6fYfsMJ3s4tNI0= + Content-Length: + - "323" + Content-Type: + - application/json + Prefer: + - return-no-content + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 table + X-Ms-Date: + - Fri, 21 Apr 2017 19:01:30 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.table.core.windows.net/table26storageentitysuitetestget + method: POST + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Dataserviceid: + - https://golangrocksonazure.table.core.windows.net/table26storageentitysuitetestget(PartitionKey='mypartitionkey',RowKey='myrowkey') + Date: + - Fri, 21 Apr 2017 19:01:29 GMT + Etag: + - W/"datetime'2017-04-21T19%3A01%3A30.1231644Z'" + Location: + - https://golangrocksonazure.table.core.windows.net/table26storageentitysuitetestget(PartitionKey='mypartitionkey',RowKey='myrowkey') + Preference-Applied: + - return-no-content + Server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + X-Content-Type-Options: + - nosniff + X-Ms-Request-Id: + - 01dca3bc-0002-0077-74d1-ba87f8000000 + X-Ms-Version: + - 2016-05-31 + status: 204 No Content + code: 204 +- request: + body: "" + form: {} + headers: + Accept: + - application/json;odata=fullmetadata + Authorization: + - SharedKey golangrocksonazure:TXUHWsilHY7Ef/c17zf5K7yTAYVBJauUBGKNBcSGjHU= + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 table + X-Ms-Date: + - Fri, 21 Apr 2017 19:01:30 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.table.core.windows.net/table26storageentitysuitetestget%28PartitionKey=%27mypartitionkey%27,%20RowKey=%27myrowkey%27%29?%24select=IsActive&timeout=30 + method: GET + response: + body: '{"odata.metadata":"https://golangrocksonazure.table.core.windows.net/$metadata#table26storageentitysuitetestget/@Element&$select=IsActive","odata.type":"golangrocksonazure.table26storageentitysuitetestget","odata.id":"https://golangrocksonazure.table.core.windows.net/table26storageentitysuitetestget(PartitionKey=''mypartitionkey'',RowKey=''myrowkey'')","odata.etag":"W/\"datetime''2017-04-21T19%3A01%3A30.1231644Z''\"","odata.editLink":"table26storageentitysuitetestget(PartitionKey=''mypartitionkey'',RowKey=''myrowkey'')","IsActive":true}' + headers: + Cache-Control: + - no-cache + Content-Type: + - application/json;odata=fullmetadata;streaming=true;charset=utf-8 + Date: + - Fri, 21 Apr 2017 19:01:29 GMT + Etag: + - W/"datetime'2017-04-21T19%3A01%3A30.1231644Z'" + Server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + X-Content-Type-Options: + - nosniff + X-Ms-Request-Id: + - 01dca3c5-0002-0077-7bd1-ba87f8000000 + X-Ms-Version: + - 2016-05-31 + status: 200 OK + code: 200 +- request: + body: "" + form: {} + headers: + Accept: + - application/json;odata=fullmetadata + Authorization: + - SharedKey golangrocksonazure:TXUHWsilHY7Ef/c17zf5K7yTAYVBJauUBGKNBcSGjHU= + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 table + X-Ms-Date: + - Fri, 21 Apr 2017 19:01:30 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.table.core.windows.net/table26storageentitysuitetestget%28PartitionKey=%27mypartitionkey%27,%20RowKey=%27myrowkey%27%29?%24select=AmountDue%2CCustomerCode%2CCustomerSince%2CIsActive%2CNumberOfOrders&timeout=30 + method: GET + response: + body: '{"odata.metadata":"https://golangrocksonazure.table.core.windows.net/$metadata#table26storageentitysuitetestget/@Element&$select=AmountDue,CustomerCode,CustomerSince,IsActive,NumberOfOrders","odata.type":"golangrocksonazure.table26storageentitysuitetestget","odata.id":"https://golangrocksonazure.table.core.windows.net/table26storageentitysuitetestget(PartitionKey=''mypartitionkey'',RowKey=''myrowkey'')","odata.etag":"W/\"datetime''2017-04-21T19%3A01%3A30.1231644Z''\"","odata.editLink":"table26storageentitysuitetestget(PartitionKey=''mypartitionkey'',RowKey=''myrowkey'')","AmountDue":200.23,"CustomerCode@odata.type":"Edm.Guid","CustomerCode":"c9da6455-213d-42c9-9a79-3e9149a57833","CustomerSince@odata.type":"Edm.DateTime","CustomerSince":"1992-12-20T21:55:00Z","IsActive":true,"NumberOfOrders@odata.type":"Edm.Int64","NumberOfOrders":"255"}' + headers: + Cache-Control: + - no-cache + Content-Type: + - application/json;odata=fullmetadata;streaming=true;charset=utf-8 + Date: + - Fri, 21 Apr 2017 19:01:29 GMT + Etag: + - W/"datetime'2017-04-21T19%3A01%3A30.1231644Z'" + Server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + X-Content-Type-Options: + - nosniff + X-Ms-Request-Id: + - 01dca3dc-0002-0077-0ed1-ba87f8000000 + X-Ms-Version: + - 2016-05-31 + status: 200 OK + code: 200 +- request: + body: "" + form: {} + headers: + Accept: + - application/json;odata=fullmetadata + Authorization: + - SharedKey golangrocksonazure:TXUHWsilHY7Ef/c17zf5K7yTAYVBJauUBGKNBcSGjHU= + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 table + X-Ms-Date: + - Fri, 21 Apr 2017 19:01:30 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.table.core.windows.net/table26storageentitysuitetestget%28PartitionKey=%27mypartitionkey%27,%20RowKey=%27myrowkey%27%29?timeout=30 + method: GET + response: + body: '{"odata.metadata":"https://golangrocksonazure.table.core.windows.net/$metadata#table26storageentitysuitetestget/@Element","odata.type":"golangrocksonazure.table26storageentitysuitetestget","odata.id":"https://golangrocksonazure.table.core.windows.net/table26storageentitysuitetestget(PartitionKey=''mypartitionkey'',RowKey=''myrowkey'')","odata.etag":"W/\"datetime''2017-04-21T19%3A01%3A30.1231644Z''\"","odata.editLink":"table26storageentitysuitetestget(PartitionKey=''mypartitionkey'',RowKey=''myrowkey'')","PartitionKey":"mypartitionkey","RowKey":"myrowkey","Timestamp@odata.type":"Edm.DateTime","Timestamp":"2017-04-21T19:01:30.1231644Z","AmountDue":200.23,"CustomerCode@odata.type":"Edm.Guid","CustomerCode":"c9da6455-213d-42c9-9a79-3e9149a57833","CustomerSince@odata.type":"Edm.DateTime","CustomerSince":"1992-12-20T21:55:00Z","IsActive":true,"NumberOfOrders@odata.type":"Edm.Int64","NumberOfOrders":"255"}' + headers: + Cache-Control: + - no-cache + Content-Type: + - application/json;odata=fullmetadata;streaming=true;charset=utf-8 + Date: + - Fri, 21 Apr 2017 19:01:29 GMT + Etag: + - W/"datetime'2017-04-21T19%3A01%3A30.1231644Z'" + Server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + X-Content-Type-Options: + - nosniff + X-Ms-Request-Id: + - 01dca3e3-0002-0077-15d1-ba87f8000000 + X-Ms-Version: + - 2016-05-31 + status: 200 OK + code: 200 +- request: + body: "" + form: {} + headers: + Accept: + - application/json;odata=nometadata + Authorization: + - SharedKey golangrocksonazure:voKWr7ShBYDaJfiGJ6tEcHNivtP4arHfBkOIVbL250w= + Prefer: + - return-no-content + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 table + X-Ms-Date: + - Fri, 21 Apr 2017 19:01:30 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.table.core.windows.net/Tables%28%27table26storageentitysuitetestget%27%29?timeout=30 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Date: + - Fri, 21 Apr 2017 19:01:29 GMT + Server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + X-Content-Type-Options: + - nosniff + X-Ms-Request-Id: + - 01dca3f2-0002-0077-24d1-ba87f8000000 + X-Ms-Version: + - 2016-05-31 + status: 204 No Content + code: 204 diff --git a/storage/recordings/StorageTableSuite/TestGet.yaml b/storage/recordings/StorageTableSuite/TestGet.yaml new file mode 100644 index 000000000000..39ff3d9ff346 --- /dev/null +++ b/storage/recordings/StorageTableSuite/TestGet.yaml @@ -0,0 +1,126 @@ +--- +version: 1 +rwmutex: {} +interactions: +- request: + body: | + {"TableName":"table25storagetablesuitetestget"} + form: {} + headers: + Accept: + - application/json;odata=nometadata + Accept-Charset: + - UTF-8 + Authorization: + - SharedKey golangrocksonazure:oFkVVxYbvsi0eavYxzYyO+K1yj1RtfoYCG8k0Nby2A8= + Content-Length: + - "48" + Content-Type: + - application/json + Prefer: + - return-no-content + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 table + X-Ms-Date: + - Fri, 21 Apr 2017 19:01:31 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.table.core.windows.net/Tables?timeout=30 + method: POST + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Dataserviceid: + - https://golangrocksonazure.table.core.windows.net/Tables('table25storagetablesuitetestget') + Date: + - Fri, 21 Apr 2017 19:01:31 GMT + Location: + - https://golangrocksonazure.table.core.windows.net/Tables('table25storagetablesuitetestget') + Preference-Applied: + - return-no-content + Server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + X-Content-Type-Options: + - nosniff + X-Ms-Request-Id: + - 01dca575-0002-0077-18d1-ba87f8000000 + X-Ms-Version: + - 2016-05-31 + status: 204 No Content + code: 204 +- request: + body: "" + form: {} + headers: + Accept: + - application/json;odata=fullmetadata + Authorization: + - SharedKey golangrocksonazure:XcVA9Plm6Mv6/t+Yz2+MGKxJpuQAvBOx866YjeMdpc8= + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 table + X-Ms-Date: + - Fri, 21 Apr 2017 19:01:31 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.table.core.windows.net/Tables%28%27table25storagetablesuitetestget%27%29?timeout=30 + method: GET + response: + body: '{"odata.metadata":"https://golangrocksonazure.table.core.windows.net/$metadata#Tables/@Element","odata.type":"golangrocksonazure.Tables","odata.id":"https://golangrocksonazure.table.core.windows.net/Tables(''table25storagetablesuitetestget'')","odata.editLink":"Tables(''table25storagetablesuitetestget'')","TableName":"table25storagetablesuitetestget"}' + headers: + Cache-Control: + - no-cache + Content-Type: + - application/json;odata=fullmetadata;streaming=true;charset=utf-8 + Date: + - Fri, 21 Apr 2017 19:01:31 GMT + Server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + X-Content-Type-Options: + - nosniff + X-Ms-Request-Id: + - 01dca57f-0002-0077-20d1-ba87f8000000 + X-Ms-Version: + - 2016-05-31 + status: 200 OK + code: 200 +- request: + body: "" + form: {} + headers: + Accept: + - application/json;odata=nometadata + Authorization: + - SharedKey golangrocksonazure:cRjC+bNv9D958nFowOo3XHO0IMUhnMDG1lfNbeLMOHw= + Prefer: + - return-no-content + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 table + X-Ms-Date: + - Fri, 21 Apr 2017 19:01:31 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.table.core.windows.net/Tables%28%27table25storagetablesuitetestget%27%29?timeout=30 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Date: + - Fri, 21 Apr 2017 19:01:31 GMT + Server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + X-Content-Type-Options: + - nosniff + X-Ms-Request-Id: + - 01dca585-0002-0077-26d1-ba87f8000000 + X-Ms-Version: + - 2016-05-31 + status: 204 No Content + code: 204 diff --git a/storage/table.go b/storage/table.go index 201690f8038e..055a900c71bb 100644 --- a/storage/table.go +++ b/storage/table.go @@ -61,6 +61,45 @@ func (t *Table) buildPath() string { return fmt.Sprintf("/%s", t.Name) } +func (t *Table) buildSpecificPath() string { + return fmt.Sprintf("%s('%s')", tablesURIPath, t.Name) +} + +// Get gets the referenced table. +// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/querying-tables-and-entities +func (t *Table) Get(timeout uint, ml MetadataLevel) error { + if ml == EmptyPayload { + return errEmptyPayload + } + + query := url.Values{ + "timeout": {strconv.FormatUint(uint64(timeout), 10)}, + } + headers := t.tsc.client.getStandardHeaders() + headers[headerAccept] = string(ml) + + uri := t.tsc.client.getEndpoint(tableServiceName, t.buildSpecificPath(), query) + resp, err := t.tsc.client.exec(http.MethodGet, uri, headers, nil, t.tsc.auth) + if err != nil { + return err + } + defer readAndCloseBody(resp.body) + + if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return err + } + + respBody, err := ioutil.ReadAll(resp.body) + if err != nil { + return err + } + err = json.Unmarshal(respBody, t) + if err != nil { + return err + } + return nil +} + // Create creates the referenced table. // This function fails if the name is not compliant // with the specification or the tables already exists. @@ -126,7 +165,7 @@ func (t *Table) Delete(timeout uint, options *TableOptions) error { path.WriteString(t.Name) path.WriteString("')") - uri := t.tsc.client.getEndpoint(tableServiceName, string(path.Bytes()), url.Values{ + uri := t.tsc.client.getEndpoint(tableServiceName, t.buildSpecificPath(), url.Values{ "timeout": {strconv.Itoa(int(timeout))}, }) diff --git a/storage/table_test.go b/storage/table_test.go index 5e89d5e11db5..fd17223dbf40 100644 --- a/storage/table_test.go +++ b/storage/table_test.go @@ -59,6 +59,26 @@ func (s *StorageTableSuite) Test_CreateTableWithAllResponsePayloadLevels(c *chk. createAndDeleteTable(cli, FullMetadata, c, "full") } +func (s *StorageTableSuite) TestGet(c *chk.C) { + cli := getTableClient(c) + rec := cli.client.appendRecorder(c) + defer rec.Stop() + + tn := tableName(c) + table := cli.GetTableReference(tn) + err := table.Create(30, EmptyPayload, nil) + c.Assert(err, chk.IsNil) + defer table.Delete(30, nil) + + err = table.Get(30, FullMetadata) + c.Assert(err, chk.IsNil) + c.Assert(table.Name, chk.Equals, tn) + c.Assert(table.OdataEditLink, chk.Not(chk.Equals), "") + c.Assert(table.OdataID, chk.Not(chk.Equals), "") + c.Assert(table.OdataMetadata, chk.Not(chk.Equals), "") + c.Assert(table.OdataType, chk.Not(chk.Equals), "") +} + func createAndDeleteTable(cli TableServiceClient, ml MetadataLevel, c *chk.C, extra string) { table := cli.GetTableReference(tableName(c, extra)) c.Assert(table.Create(30, ml, nil), chk.IsNil) diff --git a/storage/tableserviceclient.go b/storage/tableserviceclient.go index 86e7cc2e7001..769149648fc9 100644 --- a/storage/tableserviceclient.go +++ b/storage/tableserviceclient.go @@ -92,7 +92,6 @@ func (t *TableServiceClient) QueryTables(ml MetadataLevel, options *QueryTablesO query, headers := options.getParameters() uri := t.client.getEndpoint(tableServiceName, tablesURIPath, query) return t.queryTables(uri, headers, ml) - } // NextResults returns the next page of results