github.com/smugmug/godynamo@v0.0.0-20151122084750-7913028f6623/endpoints/update_table/update_table_test.go (about)

     1  package update_table
     2  
     3  import (
     4  	"encoding/json"
     5  	"testing"
     6  )
     7  
     8  func TestNil(t *testing.T) {
     9  	s := NewUpdateTable()
    10  	_,_,err := s.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{`{"TableName":"Thread","ProvisionedThroughput":{"ReadCapacityUnits":10,"WriteCapacityUnits":10}}`}
    18  	for _, v := range s {
    19  		var u UpdateTable
    20  		um_err := json.Unmarshal([]byte(v), &u)
    21  		if um_err != nil {
    22  			t.Errorf("cannot unmarshal\n")
    23  		}
    24  		_, jerr := json.Marshal(u)
    25  		if jerr != nil {
    26  			t.Errorf("cannot marshal\n")
    27  		}
    28  	}
    29  }
    30  
    31  func TestResponseUnmarshal(t *testing.T) {
    32  	s := []string{`{"TableDescription":{"AttributeDefinitions":[{"AttributeName":"ForumName","AttributeType":"S"},{"AttributeName":"LastPostDateTime","AttributeType":"S"},{"AttributeName":"Subject","AttributeType":"S"}],"CreationDateTime":1.363801528686E9,"ItemCount":0,"KeySchema":[{"AttributeName":"ForumName","KeyType":"HASH"},{"AttributeName":"Subject","KeyType":"RANGE"}],"LocalSecondaryIndexes":[{"IndexName":"LastPostIndex","IndexSizeBytes":0,"ItemCount":0,"KeySchema":[{"AttributeName":"ForumName","KeyType":"HASH"},{"AttributeName":"LastPostDateTime","KeyType":"RANGE"}],"Projection":{"ProjectionType":"KEYS_ONLY"}}],"ProvisionedThroughput":{"LastIncreaseDateTime":1.363801701282E9,"NumberOfDecreasesToday":0,"ReadCapacityUnits":5,"WriteCapacityUnits":5},"TableName":"Thread","TableSizeBytes":0,"TableStatus":"UPDATING"}}`}
    33  	for _, v := range s {
    34  		var u Response
    35  		um_err := json.Unmarshal([]byte(v), &u)
    36  		if um_err != nil {
    37  			t.Errorf("cannot unmarshal\n")
    38  		}
    39  		_, jerr := json.Marshal(u)
    40  		if jerr != nil {
    41  			t.Errorf("cannot marshal\n")
    42  		}
    43  	}
    44  }