『 19y/o 』 『 he/him 』
- 🤥 I've created my readme with this.
Simple Rest API that acts like a bank.
『 19y/o 』 『 he/him 』
When updating the TransactionDetails of a Transaction by using:
{
"description": "silly description"
}
the Tags Column in the database gets overwritten by null, which leads to a problem when getting the transaction with its transaction details.
It should be stay possible to update the details by using:
{
"description": "silly description",
"tags": ["silly tag"]
}
AND
{
"description": "silly description"
}
OR
{
"tags": ["silly tag"]
}
Write some tests to check if the endpoints do what they have to do
e.g.
package main_test
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"yourpackage/dataservice"
"yourpackage/restapi"
"yourpackage/restapi/mocks"
)
func TestGetUser(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
// Mock-Implementierung der Datenzugriffsschicht
mockDataService := mocks.NewMockDataService(ctrl)
mockDataService.EXPECT().GetUser(1).Return(&dataservice.User{ID: 1, Name: "John"}, nil)
// REST-API-Handler initialisieren und den DataService setzen
apiHandler := restapi.NewAPIHandler()
apiHandler.SetDataService(mockDataService)
// HTTP-Request und -Response simulieren
req, _ := http.NewRequest("GET", "/users/1", nil)
rec := httptest.NewRecorder()
// Handler aufrufen
apiHandler.ServeHTTP(rec, req)
// Überprüfen der HTTP-Response
assert.Equal(t, http.StatusOK, rec.Code)
assert.Equal(t, `{"id":1,"name":"John"}`, rec.Body.String())
}
When try getting an account by a no existing account number using e.g.:
GET http://localhost:3000/account/?number=123456
the server returns the following json response:
{
"created_at": "0001-01-01T00:00:00Z"
}
and status 200
Instead it should return an error message and status 400
Bad Request
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.