func testPutQuery(t *testing.T, table *Table, expected string) { var key *Key if table.Key.HasRange() { key = &Key{HashKey: "NewHashKeyVal", RangeKey: "12"} } else { key = &Key{HashKey: "NewHashKeyVal"} } data := map[string]interface{}{ "Attr1": "Attr1Val", "Attr2": 12} item, err := dynamizer.ToDynamo(data) if err != nil { t.Fatal(err) } q := NewDynamoQuery(table) if err := q.AddItem(key, item); err != nil { t.Fatal(err) } actual, err := q.Marshal() if err != nil { t.Fatal(err) } compareJSONStrings(t, expected, actual) }
func (t *Table) PutDocument(key *Key, data interface{}) error { item, err := dynamizer.ToDynamo(data) if err != nil { return err } q := NewDynamoQuery(t) q.AddItem(key, item) jsonResponse, err := t.Server.queryServer(target("PutItem"), q) if err != nil { return err } // A successful PUT returns an empty JSON object. Simply checking for valid // JSON here. var response map[string]interface{} err = json.Unmarshal(jsonResponse, &response) if err != nil { return err } return nil }