Create initial backend (#7)

Closes #3

Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
2025-05-08 10:02:30 +02:00
parent 539c6412a7
commit 1baa1afb07
8 changed files with 552 additions and 1 deletions

25
backend/api_test.go Normal file
View File

@@ -0,0 +1,25 @@
package main
import (
"testing"
)
import "github.com/gavv/httpexpect/v2"
func startServer(t *testing.T) {
config := ServerConfig{
Datasource: ":memory:",
Port: "8181",
Started: make(chan bool),
}
go start(t.Context(), &config)
<-config.Started
}
func TestGetUsers(t *testing.T) {
startServer(t)
e := httpexpect.Default(t, "http://localhost:8181/api")
result := e.GET("/users").Expect().Status(200).JSON()
result.Array().Length().IsEqual(2)
result.Path("$[0].name").InList("Seeseemelk", "Huffle")
result.Path("$[1].name").InList("Seeseemelk", "Huffle")
}