Ejemplo n.º 1
0
func testPostTransactionInBadFormat(t *testing.T) {
	dTransaction := &dummyTransaction{
		BadField: "bad value",
	}

	tests.PerformTestRequest(endpointPath, ActionCreate, api.POST, http.StatusBadRequest, nil, dTransaction, t)
}
Ejemplo n.º 2
0
func testPostTransactionNotIntegral(t *testing.T) {
	transaction := &models.Transaction{
		ID:       bson.NewObjectId(),
		Payer:    identity.ApplicationUser{ID: bson.NewObjectId()},
		Currency: "USD",
	}

	tests.PerformTestRequest(endpointPath, ActionCreate, api.POST, http.StatusBadRequest, nil, transaction, t)
}
Ejemplo n.º 3
0
func testGetTransactionWithGoodIDParam(t *testing.T, id bson.ObjectId) {
	params := url.Values{}
	params.Add("transactionId", id.Hex())

	rw := tests.PerformTestRequest(endpointPath, ActionGet, api.GET, http.StatusOK, params, nil, t)

	body := rw.Body.String()
	if len(body) == 0 {
		t.Error("Response body is empty or in a corrupt format:", body)
	}
}
Ejemplo n.º 4
0
func testPostTransactionInGoodFormat(t *testing.T) bson.ObjectId {
	transaction := &models.Transaction{
		ID:       bson.NewObjectId(),
		Payer:    identity.ApplicationUser{ID: bson.NewObjectId()},
		Receiver: identity.ApplicationUser{ID: bson.NewObjectId()},
		Type:     models.TransactionTypeCash,
		Ammount:  216.365,
		Currency: "USD",
	}

	rw := tests.PerformTestRequest(endpointPath, ActionCreate, api.POST, http.StatusCreated, nil, transaction, t)

	body := rw.Body.String()
	if len(body) == 0 {
		t.Error("Response body is empty or in deteriorated format:", body)
	}

	return transaction.ID
}
Ejemplo n.º 5
0
func testGetTransactionWithBadIDParam(t *testing.T) {
	params := url.Values{}
	params.Add("transactionId", "2as456fas4")

	tests.PerformTestRequest(endpointPath, ActionGet, api.GET, http.StatusBadRequest, params, nil, t)
}
Ejemplo n.º 6
0
func testGetTransactionWithInexistentIDInDB(t *testing.T) {
	params := url.Values{}
	params.Add("transactionId", bson.NewObjectId().Hex())

	tests.PerformTestRequest(endpointPath, ActionGet, api.GET, http.StatusNotFound, params, nil, t)
}