github.com/smugmug/godynamo@v0.0.0-20151122084750-7913028f6623/tests/delete_item-livetest.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "github.com/smugmug/godynamo/conf" 6 "github.com/smugmug/godynamo/conf_file" 7 conf_iam "github.com/smugmug/godynamo/conf_iam" 8 delete_item "github.com/smugmug/godynamo/endpoints/delete_item" 9 keepalive "github.com/smugmug/godynamo/keepalive" 10 "github.com/smugmug/godynamo/types/attributevalue" 11 "log" 12 "net/http" 13 "os" 14 ) 15 16 func main() { 17 conf_file.Read() 18 conf.Vals.ConfLock.RLock() 19 if conf.Vals.Initialized == false { 20 panic("the conf.Vals global conf struct has not been initialized") 21 } 22 23 // launch a background poller to keep conns to aws alive 24 if conf.Vals.Network.DynamoDB.KeepAlive { 25 log.Printf("launching background keepalive") 26 go keepalive.KeepAlive([]string{}) 27 } 28 29 // deal with iam, or not 30 if conf.Vals.UseIAM { 31 iam_ready_chan := make(chan bool) 32 go conf_iam.GoIAM(iam_ready_chan) 33 _ = <-iam_ready_chan 34 } 35 conf.Vals.ConfLock.RUnlock() 36 37 tn := "test-godynamo-livetest" 38 tablename1 := tn 39 fmt.Printf("tablename1: %s\n", tablename1) 40 41 // DELETE AN ITEM 42 del_item1 := delete_item.NewDeleteItem() 43 del_item1.TableName = tablename1 44 del_item1.Key["TheHashKey"] = &attributevalue.AttributeValue{S: "AHashKey1"} 45 del_item1.Key["TheRangeKey"] = &attributevalue.AttributeValue{N: "1"} 46 47 body, code, err := del_item1.EndpointReq() 48 if err != nil || code != http.StatusOK { 49 fmt.Printf("fail delete %d %v %s\n", code, err, string(body)) 50 os.Exit(1) 51 } 52 fmt.Printf("%v\n%v\n,%v\n", string(body), code, err) 53 }