Exemplo n.º 1
0
Arquivo: all_test.go Projeto: reds/aws
func TestConfig(t *testing.T) {
	cfg, err := config.LoadConfig("awsTestSuite.cfg", "dynamodb")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(cfg)
}
Exemplo n.º 2
0
Arquivo: all_test.go Projeto: reds/aws
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)
}
Exemplo n.º 3
0
Arquivo: all_test.go Projeto: reds/aws
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)
}
Exemplo n.º 4
0
Arquivo: all_test.go Projeto: reds/aws
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)
}
Exemplo n.º 5
0
Arquivo: all_test.go Projeto: reds/aws
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)
}
Exemplo n.º 6
0
Arquivo: all_test.go Projeto: reds/aws
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)
}
Exemplo n.º 7
0
Arquivo: all_test.go Projeto: reds/aws
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)
			}
		}
	}
}