github.com/smugmug/godynamo@v0.0.0-20151122084750-7913028f6623/endpoints/delete_table/delete_table_test.go (about) 1 package delete_table 2 3 import ( 4 "encoding/json" 5 "testing" 6 ) 7 8 func TestNil(t *testing.T) { 9 d := NewDeleteTable() 10 _,_,err := d.EndpointReqWithConf(nil) 11 if err == nil { 12 t.Errorf("nil conf should result in error") 13 } 14 } 15 16 func TestRequestUnmarshal(t *testing.T) { 17 s := []string{ 18 `{"TableName": "Reply"}`, 19 } 20 for _, v := range s { 21 var u DeleteTable 22 um_err := json.Unmarshal([]byte(v), &u) 23 if um_err != nil { 24 t.Errorf("cannot unmarshal\n") 25 } 26 _, jerr := json.Marshal(u) 27 if jerr != nil { 28 t.Errorf("cannot marshal\n") 29 } 30 } 31 } 32 33 func TestResponseUnmarshal(t *testing.T) { 34 s := []string{ 35 `{"TableDescription":{"ItemCount":0,"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":5,"WriteCapacityUnits":5},"TableName":"Reply","TableSizeBytes":0,"TableStatus":"DELETING"}}`, 36 } 37 for _, v := range s { 38 var u Response 39 um_err := json.Unmarshal([]byte(v), &u) 40 if um_err != nil { 41 t.Errorf("cannot unmarshal\n") 42 } 43 _, jerr := json.Marshal(u) 44 if jerr != nil { 45 t.Errorf("cannot marshal\n") 46 } 47 } 48 }