mirror of
https://github.com/vcscsvcscs/GenerationsHeritage.git
synced 2025-08-14 06:49:05 +02:00
fix integration test to work, init integration tests
This commit is contained in:
16
apps/db-adapter/integration-tests/admin.go
Normal file
16
apps/db-adapter/integration-tests/admin.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package integration_tests
|
||||
|
||||
func CreateAdminRelationship() {
|
||||
}
|
||||
|
||||
func DeleteAdminRelationship() {
|
||||
}
|
||||
|
||||
func GetAdminRelationship() {
|
||||
}
|
||||
|
||||
func GetProfileAdmins() {
|
||||
}
|
||||
|
||||
func GetManagedProfiles() {
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"first_name": "Alice",
|
||||
"last_name": "Wonderland",
|
||||
"born": "1990-06-01",
|
||||
"limit": 100,
|
||||
"mothers_first_name": "Mary",
|
||||
"mothers_last_name": "Smith",
|
||||
"email": "alice@example.com"
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"invite_code": "INV123456",
|
||||
"person": {
|
||||
"first_name": "Bob",
|
||||
"last_name": "Builder",
|
||||
"born": "1985-11-25",
|
||||
"limit": 200,
|
||||
"mothers_first_name": "Linda",
|
||||
"mothers_last_name": "Builder",
|
||||
"email": "bob@example.com"
|
||||
}
|
||||
}
|
16
apps/db-adapter/integration-tests/person.go
Normal file
16
apps/db-adapter/integration-tests/person.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package integration_tests
|
||||
|
||||
func CreatePerson() {
|
||||
}
|
||||
|
||||
func GetPersonById() {
|
||||
}
|
||||
|
||||
func SoftDeletePerson() {
|
||||
}
|
||||
|
||||
func UpdatePerson() {
|
||||
}
|
||||
|
||||
func HardDeletePerson() {
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package integration_tests
|
||||
|
||||
func CreatePersonAndRelationship() {
|
||||
}
|
7
apps/db-adapter/integration-tests/person_family_tree.go
Normal file
7
apps/db-adapter/integration-tests/person_family_tree.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package integration_tests
|
||||
|
||||
func GetFamilyTreeById() {
|
||||
}
|
||||
|
||||
func GetFamilyTreeWithSpousesById() {
|
||||
}
|
114
apps/db-adapter/integration-tests/person_google.go
Normal file
114
apps/db-adapter/integration-tests/person_google.go
Normal file
@@ -0,0 +1,114 @@
|
||||
package integration_tests
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestPersonGoogle runs integration tests for the Person Google API endpoints.
|
||||
// It requires a running instance of the db-adapter and a valid dbAdapterUri.
|
||||
// The tests include creating a person by Google ID, and getting a person by Google ID.
|
||||
// It does not include creating a person by Google ID with an invite code.
|
||||
func TestPersonGoogle(dbAdapterUri string) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
client := &http.Client{}
|
||||
|
||||
t.Run("CreatePersonByGoogleId", createPersonByGoogleIdTest(dbAdapterUri, client))
|
||||
t.Run("GetPersonByGoogleId", getPersonByGoogleIdTest(dbAdapterUri, client))
|
||||
}
|
||||
}
|
||||
|
||||
func getPersonByGoogleIdTest(dbAdapterUri string, client *http.Client) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
url := dbAdapterUri + "/person/google/test-google-id"
|
||||
|
||||
req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, url, http.NoBody)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Send the request
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
|
||||
var responseBody map[string]any
|
||||
err = json.NewDecoder(resp.Body).Decode(&responseBody)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Validate the response
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
_, ok := responseBody["Id"]
|
||||
require.True(t, ok)
|
||||
|
||||
require.Equal(t, "Alice", responseBody["Props"].(map[string]any)["first_name"])
|
||||
require.Equal(t, "Wonderland", responseBody["Props"].(map[string]any)["last_name"])
|
||||
}
|
||||
}
|
||||
|
||||
//go:embed payloads/create_person_with_invite_code.json
|
||||
var create_person_with_invite_code []byte
|
||||
|
||||
func CreatePersonByGoogleIdAndInviteCodeTest(dbAdapterUri string, client *http.Client) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
url := dbAdapterUri + "/person/google/test-google-id"
|
||||
|
||||
req, err := http.NewRequestWithContext(t.Context(), http.MethodPatch, url, bytes.NewBuffer(create_person_with_invite_code))
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
// Send the request
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
|
||||
var responseBody map[string]any
|
||||
err = json.NewDecoder(resp.Body).Decode(&responseBody)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Validate the response
|
||||
t.Log("Response Status Code: ", responseBody)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
_, ok := responseBody["Id"]
|
||||
require.True(t, ok)
|
||||
|
||||
require.Equal(t, "John", responseBody["Props"].(map[string]any)["first_name"])
|
||||
require.Equal(t, "Doe", responseBody["Props"].(map[string]any)["last_name"])
|
||||
}
|
||||
}
|
||||
|
||||
//go:embed payloads/create_person.json
|
||||
var create_person []byte
|
||||
|
||||
func createPersonByGoogleIdTest(dbAdapterUri string, client *http.Client) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
url := dbAdapterUri + "/person/google/test-google-id"
|
||||
|
||||
req, err := http.NewRequestWithContext(t.Context(), http.MethodPost, url, bytes.NewBuffer(create_person))
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
// Send the request
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
|
||||
var responseBody map[string]any
|
||||
err = json.NewDecoder(resp.Body).Decode(&responseBody)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Validate the response
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
_, ok := responseBody["Id"]
|
||||
require.True(t, ok)
|
||||
|
||||
require.Equal(t, "Alice", responseBody["Props"].(map[string]any)["first_name"])
|
||||
require.Equal(t, "Wonderland", responseBody["Props"].(map[string]any)["last_name"])
|
||||
}
|
||||
}
|
4
apps/db-adapter/integration-tests/person_recipes.go
Normal file
4
apps/db-adapter/integration-tests/person_recipes.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package integration_tests
|
||||
|
||||
func GetRecipesByPersonId() {
|
||||
}
|
9
apps/db-adapter/integration-tests/recipe_relationship.go
Normal file
9
apps/db-adapter/integration-tests/recipe_relationship.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package integration_tests
|
||||
|
||||
func DeleteRecipeRelationship() {
|
||||
|
||||
}
|
||||
|
||||
func CreateRecipeRelationship() {
|
||||
|
||||
}
|
10
apps/db-adapter/integration-tests/recipes.go
Normal file
10
apps/db-adapter/integration-tests/recipes.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package integration_tests
|
||||
|
||||
func SoftDeleteRecipe() {
|
||||
}
|
||||
|
||||
func UpdateRecipe() {
|
||||
}
|
||||
|
||||
func HardDeleteRecipe() {
|
||||
}
|
13
apps/db-adapter/integration-tests/relationship.go
Normal file
13
apps/db-adapter/integration-tests/relationship.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package integration_tests
|
||||
|
||||
func CreateRelationship() {
|
||||
}
|
||||
|
||||
func UpdateRelationship() {
|
||||
}
|
||||
|
||||
func GetRelationship() {
|
||||
}
|
||||
|
||||
func DeleteRelationship() {
|
||||
}
|
Reference in New Issue
Block a user