Save internal_name and display_name in channel
This commit is contained in:
@@ -203,7 +203,14 @@ func AssertMultiNonEmpty(t *testing.T, key string, args ...any) {
|
||||
|
||||
func AssertMappedSet[T langext.OrderedConstraint](t *testing.T, key string, expected []T, values []gin.H, objkey string) {
|
||||
|
||||
actual := langext.ArrMap(values, func(v gin.H) T { return v[objkey].(T) })
|
||||
actual := make([]T, 0)
|
||||
for idx, vv := range values {
|
||||
if tv, ok := vv[objkey].(T); ok {
|
||||
actual = append(actual, tv)
|
||||
} else {
|
||||
TestFailFmt(t, "[%s]->[%d] is wrong type (expected: %T, actual: %T)", key, idx, *new(T), vv)
|
||||
}
|
||||
}
|
||||
|
||||
langext.Sort(actual)
|
||||
langext.Sort(expected)
|
||||
|
||||
@@ -86,8 +86,10 @@ var userExamples = []userex{
|
||||
{9, true, "UniqueUnicorn", "Galaxy Quest", "2023.1", "ANDROID", "FCM_TOK_EX_010", ""},
|
||||
{10, false, "", "", "", "", "", ""},
|
||||
{11, false, "", "", "", "", "", "ANDROID|v2|PURCHASED:PRO_TOK_002"},
|
||||
{12, true, "ChanTester1", "StarfireXX", "1.x", "IOS", "FCM_TOK_EX_012", ""},
|
||||
{13, true, "ChanTester2", "StarfireXX", "1.x", "IOS", "FCM_TOK_EX_013", ""},
|
||||
{12, true, "NoMessageUser", "Ocean Explorer", "737edc01", "IOS", "FCM_TOK_EX_014", ""},
|
||||
{13, false, "EmptyUser", "", "", "", "", ""},
|
||||
{14, true, "ChanTester1", "StarfireXX", "1.x", "IOS", "FCM_TOK_EX_012", ""},
|
||||
{15, true, "ChanTester2", "StarfireXX", "1.x", "IOS", "FCM_TOK_EX_013", ""},
|
||||
}
|
||||
|
||||
var clientExamples = []clientex{
|
||||
@@ -267,14 +269,14 @@ var messageExamples = []msgex{
|
||||
{11, "Promotions", "", PX, AKEY, "Join Our VIP Club and Enjoy Exclusive Benefits", "Sign up for our VIP club and enjoy exclusive benefits like early access to sales, special offers, and personalized service. Don't miss out on this exclusive opportunity.", timeext.FromHours(2.32)},
|
||||
{11, "Promotions", "", P2, SKEY, "Summer Clearance: Save Up to 75% on Your Favorite Products", "It's time for our annual summer clearance sale! Save up to 75% on your favorite products, from clothing and accessories to home decor and more.", timeext.FromHours(1.87)},
|
||||
|
||||
{12, "", "", P0, SKEY, "New Product Launch", "We are excited to announce the launch of our new product, the XYZ widget", 0},
|
||||
{12, "chan_self_subscribed", "", P0, SKEY, "Important Update", "We have released a critical update", 0},
|
||||
{12, "chan_self_unsub", "", P0, SKEY, "Reminder: Upcoming Maintenance", "", 0},
|
||||
{14, "", "", P0, SKEY, "New Product Launch", "We are excited to announce the launch of our new product, the XYZ widget", 0},
|
||||
{14, "chan_self_subscribed", "", P0, SKEY, "Important Update", "We have released a critical update", 0},
|
||||
{14, "chan_self_unsub", "", P0, SKEY, "Reminder: Upcoming Maintenance", "", 0},
|
||||
|
||||
{13, "", "", P0, SKEY, "New Feature Available", "ability to schedule appointments", 0},
|
||||
{13, "chan_other_nosub", "", P0, SKEY, "Account Suspended", "Please contact us", 0},
|
||||
{13, "chan_other_request", "", P0, SKEY, "Invitation to Beta Test", "", 0},
|
||||
{13, "chan_other_accepted", "", P0, SKEY, "New Blog Post", "Congratulations on your promotion! We are proud", 0},
|
||||
{15, "", "", P0, SKEY, "New Feature Available", "ability to schedule appointments", 0},
|
||||
{15, "chan_other_nosub", "", P0, SKEY, "Account Suspended", "Please contact us", 0},
|
||||
{15, "chan_other_request", "", P0, SKEY, "Invitation to Beta Test", "", 0},
|
||||
{15, "chan_other_accepted", "", P0, SKEY, "New Blog Post", "Congratulations on your promotion! We are proud", 0},
|
||||
}
|
||||
|
||||
type DefData struct {
|
||||
@@ -373,6 +375,12 @@ func InitDefaultData(t *testing.T, ws *logic.Application) DefData {
|
||||
RequestPost[gin.H](t, baseUrl, "/", body)
|
||||
}
|
||||
|
||||
// create manual channels
|
||||
|
||||
{
|
||||
RequestAuthPost[Void](t, users[9].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels", users[9].UID), gin.H{"name": "manual@chan"})
|
||||
}
|
||||
|
||||
// Sub/Unsub for Users 12+13
|
||||
|
||||
{
|
||||
|
||||
@@ -163,10 +163,10 @@ func RequestAny[TResult any](t *testing.T, akey string, method string, baseURL s
|
||||
return data
|
||||
}
|
||||
|
||||
func RequestAuthAnyShouldFail(t *testing.T, akey string, method string, baseURL string, urlSuffix string, body any, statusCode int, errcode apierr.APIError) {
|
||||
func RequestAuthAnyShouldFail(t *testing.T, akey string, method string, baseURL string, urlSuffix string, body any, expectedStatusCode int, errcode apierr.APIError) {
|
||||
client := http.Client{}
|
||||
|
||||
TPrintf("[-> REQUEST] (%s) %s%s [%s] (should-fail with %d/%d)\n", method, baseURL, urlSuffix, langext.Conditional(akey == "", "NO AUTH", "AUTH"), statusCode, errcode)
|
||||
TPrintf("[-> REQUEST] (%s) %s%s [%s] (should-fail with %d/%d)\n", method, baseURL, urlSuffix, langext.Conditional(akey == "", "NO AUTH", "AUTH"), expectedStatusCode, errcode)
|
||||
|
||||
bytesbody := make([]byte, 0)
|
||||
contentType := ""
|
||||
@@ -224,17 +224,17 @@ func RequestAuthAnyShouldFail(t *testing.T, akey string, method string, baseURL
|
||||
TPrintln("")
|
||||
TPrintf("---------------- RESPONSE (%d) ----------------\n", resp.StatusCode)
|
||||
TPrintln(langext.TryPrettyPrintJson(string(respBodyBin)))
|
||||
if (statusCode != 0 && resp.StatusCode != statusCode) || (statusCode == 0 && resp.StatusCode == 200) {
|
||||
if (expectedStatusCode != 0 && resp.StatusCode != expectedStatusCode) || (expectedStatusCode == 0 && resp.StatusCode == 200) {
|
||||
TryPrintTraceObj("---------------- -------- ----------------", respBodyBin, "")
|
||||
}
|
||||
TPrintln("---------------- -------- ----------------")
|
||||
TPrintln("")
|
||||
|
||||
if statusCode != 0 && resp.StatusCode != statusCode {
|
||||
TestFailFmt(t, "Statuscode != %d (expected failure)", statusCode)
|
||||
if expectedStatusCode != 0 && resp.StatusCode != expectedStatusCode {
|
||||
TestFailFmt(t, "Statuscode != %d (expected failure, but got %d)", expectedStatusCode, resp.StatusCode)
|
||||
}
|
||||
if statusCode == 0 && resp.StatusCode == 200 {
|
||||
TestFailFmt(t, "Statuscode == %d (expected failure)", resp.StatusCode)
|
||||
if expectedStatusCode == 0 && resp.StatusCode == 200 {
|
||||
TestFailFmt(t, "Statuscode == %d (expected any failure, but got %d)", resp.StatusCode, resp.StatusCode)
|
||||
}
|
||||
|
||||
var data gin.H
|
||||
|
||||
Reference in New Issue
Block a user