Exemple #1
0
func TestConfig(t *testing.T) {
	cfg, err := config.LoadConfig("awsTestSuite.cfg", "dynamodb")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(cfg)
}
Exemple #2
0
func TestDescribeTables(t *testing.T) {
	cfg, err := config.LoadConfig("/tmp/aws.cfg", "dynamodb")
	if err != nil {
		t.Fatal(err)
	}
	ltr, err := DescribeTable(cfg, &DescribeTableRequest{"mprtest"})
	if err != nil {
		t.Fatal(err)
	}
	t.Log(ltr)
}
Exemple #3
0
func TestPutItem(t *testing.T) {
	cfg, err := config.LoadConfig("/tmp/aws.cfg", "dynamodb")
	if err != nil {
		t.Fatal(cfg, err)
	}
	tr, err := PutItem(cfg, &PutItemRequest{TableName: "mprtest", Item: map[string]AttributeValue{"id": {S: "dyntest"}, "favs": {SS: []string{"f1", "f2", "f4"}}, "ts": {N: "90"}}})
	if err != nil {
		t.Fatal(err)
	}
	t.Log(tr)
}
Exemple #4
0
func TestGetItem(t *testing.T) {
	cfg, err := config.LoadConfig("/tmp/aws.cfg", "dynamodb")
	if err != nil {
		t.Fatal(cfg, err)
	}
	tr, err := GetItem(cfg, &GetItemRequest{TableName: "mprtest", Key: map[string]AttributeValue{"id": {S: "dyntest"}, "ts": {N: "80"}}, AttributesToGet: []string{"favs", "hides"}})
	if err != nil {
		t.Fatal(err)
	}
	t.Log(tr)
}
Exemple #5
0
func TestUpdateItem(t *testing.T) {
	cfg, err := config.LoadConfig("/tmp/aws.cfg", "dynamodb")
	if err != nil {
		t.Fatal(cfg, err)
	}
	r, err := UpdateItem(cfg, &UpdateItemRequest{TableName: "mprtest", Key: map[string]AttributeValue{"id": {S: "dyntest"}}, AttributeUpdates: map[string]AttributeUpdateValue{"hides": {Action: "DELETE", Value: AttributeValue{SS: []string{"a", "d"}}}}})
	if err != nil {
		t.Fatal(err)
	}
	t.Log(r)
}
Exemple #6
0
func TestListTables(t *testing.T) {
	cfg, err := config.LoadConfig("/tmp/aws.cfg", "dynamodb")
	if err != nil {
		t.Fatal(err)
	}
	ltr, err := ListTables(cfg, nil)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(ltr)
	ltr, err = ListTables(cfg, &ListTablesRequest{"mprtest", 10})
	if err != nil {
		t.Fatal(err)
	}
	t.Log(ltr)
	ltr, err = ListTables(cfg, &ListTablesRequest{"a", 10})
	if err != nil {
		t.Fatal(err)
	}
	t.Log(ltr)
}
Exemple #7
0
func TestDir(t *testing.T) {
	dir, err := os.Open(suiteDir)
	if err != nil {
		t.Fatal(err)
	}
	files, err := dir.Readdirnames(-1)
	if err != nil {
		t.Fatal(err)
	}
	cfg, err := config.LoadConfig("awsTestSuite.cfg", "dynamodb")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(cfg)

	for _, file := range files {
		if strings.HasSuffix(file, ".req") {
			file = suiteDir + "/" + file[:len(file)-4]
			req := reqFile2req(t, file+".req")
			if req == nil {
				t.Log("skipping", file, "(file2req)")
				continue
				//				t.Fatal("error parsing", file)
			}
			t.Log(file)
			creq, _ := req2canonical(req)
			if !compFile2String(t, file+".creq", creq) {
				t.Logf("%#v", req)
				t.Logf("%#v", creq)
				t.Log("skipping", file, "(cannonical)")
				continue
			}
			SignV4(req, "host", cfg.Region, cfg.AccessKeyId, cfg.Secret)
			auth := req.Header["Authorization"][0]
			if !compFile2String(t, file+".authz", auth) {
				t.Fatal("authorization", file)
			}
		}
	}
}