Create initial backend (#7)
Closes #3 Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
25
backend/api_test.go
Normal file
25
backend/api_test.go
Normal 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")
|
||||
}
|
||||
Reference in New Issue
Block a user