Add various deleted flags to entities | Add active to subscriptions | Add DeleteUser && DeleteChannel endpoints
Some checks failed
Build Docker and Deploy / Deploy to Server (push) Blocked by required conditions
Build Docker and Deploy / Build Docker Container (push) Successful in 53s
Build Docker and Deploy / Run Unit-Tests (push) Has been cancelled

This commit is contained in:
2025-04-13 16:12:15 +02:00
parent aac34ef738
commit 67882713f9
47 changed files with 2453 additions and 243 deletions

View File

@@ -177,6 +177,14 @@ func AssertTrue(t *testing.T, key string, v bool) {
}
}
func AssertFalse(t *testing.T, key string, v bool) {
if v {
t.Errorf("AssertFalse(%s) failed", key)
t.Error(string(debug.Stack()))
t.FailNow()
}
}
func AssertNotDefault[T comparable](t *testing.T, key string, v T) {
if v == *new(T) {
t.Errorf("AssertNotDefault(%s) failed", key)
@@ -307,7 +315,7 @@ func AssertAny(v any) {
}
func AssertNil(t *testing.T, key string, v any) {
if v != nil {
if !langext.IsNil(v) {
t.Errorf("AssertNil(%s) failed - actual value:\n%+v", key, v)
t.Error(string(debug.Stack()))
t.FailNow()
@@ -315,7 +323,7 @@ func AssertNil(t *testing.T, key string, v any) {
}
func AssertNotNil(t *testing.T, key string, v any) {
if v == nil {
if langext.IsNil(v) {
t.Errorf("AssertNotNil(%s) failed", key)
t.Error(string(debug.Stack()))
t.FailNow()

View File

@@ -467,8 +467,10 @@ func InitDefaultData(t *testing.T, ws *logic.Application) DefData {
users[i].Subscriptions = langext.ArrMap(r0.Subs, func(v ssub) string { return v.ID })
}
// Sub/Unsub for Users 12+13
// Sub/Unsub for Users 14+15
// - User 14 is not subscribed to (own) channel "chan_self_unsub"
// - User 14 has an unconfirmed request to User15's channel "chan_other_request"
// - User 14 has a confirmed+active subscription to User15's channel "chan_other_accepted"
{
doUnsubscribe(t, baseUrl, users[14], users[14], "chan_self_unsub")
doSubscribe(t, baseUrl, users[14], users[15], "chan_other_request")

View File

@@ -0,0 +1,34 @@
package util
import (
"fmt"
"testing"
)
func FindSubscriptionByChanName(t *testing.T, baseUrl string, subscriber Userdat, ownerUID string, chanName string) (subscriptionID string, channelID string) {
type subobj struct {
SubscriptionId string `json:"subscription_id"`
ChannelId string `json:"channel_id"`
ChannelInternalName string `json:"channel_internal_name"`
ChannelOwnerUserId string `json:"channel_owner_user_id"`
Confirmed bool `json:"confirmed"`
Active bool `json:"active"`
}
type sublist struct {
Subscriptions []subobj `json:"subscriptions"`
}
subs := RequestAuthGet[sublist](t, subscriber.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/subscriptions?direction=outgoing", subscriber.UID))
for _, sub := range subs.Subscriptions {
if sub.ChannelOwnerUserId == ownerUID && sub.ChannelInternalName == chanName {
fullSub := RequestAuthGet[subobj](t, subscriber.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/subscriptions/%s", subscriber.UID, sub.SubscriptionId))
if fullSub.ChannelOwnerUserId == ownerUID && fullSub.ChannelInternalName == chanName {
return fullSub.SubscriptionId, fullSub.ChannelId
}
}
}
t.Fatalf("Could not find subscription for user %s to channel %s owned by %s", subscriber.UID, chanName, ownerUID)
return "", ""
}