Tests[ListChannelsDefault, ListChannelsOwned, ListChannelsSubscribedAny, ListChannelsAllAny, ListChannelsSubscribed, ListChannelsAll]
This commit is contained in:
@@ -150,6 +150,41 @@ func TestChannelNameNormalization(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestListChannelsDefault(t *testing.T) {
|
||||
ws, baseUrl, stop := tt.StartSimpleWebserver(t)
|
||||
defer stop()
|
||||
|
||||
data := tt.InitDefaultData(t, ws)
|
||||
|
||||
type chanlist struct {
|
||||
Channels []gin.H `json:"channels"`
|
||||
}
|
||||
|
||||
testdata := map[int][]string{
|
||||
0: {"main", "chatting chamber", "unicôdé häll \U0001f92a", "promotions", "reminders"},
|
||||
1: {"main", "private"},
|
||||
2: {"main", "ü", "ö", "ä"},
|
||||
3: {"main", "\U0001f5ff", "innovations", "reminders"},
|
||||
4: {"main"},
|
||||
5: {"main", "test1", "test2", "test3", "test4", "test5"},
|
||||
6: {"main", "security", "lipsum"},
|
||||
7: {"main"},
|
||||
8: {"main"},
|
||||
9: {"main", "manual@chan"},
|
||||
10: {"main"},
|
||||
11: {"promotions"},
|
||||
12: {},
|
||||
13: {},
|
||||
14: {"main", "chan_self_subscribed", "chan_self_unsub"},
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"},
|
||||
}
|
||||
|
||||
for k, v := range testdata {
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels", data.User[k].UID))
|
||||
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
|
||||
}
|
||||
}
|
||||
|
||||
func TestListChannelsOwned(t *testing.T) {
|
||||
ws, baseUrl, stop := tt.StartSimpleWebserver(t)
|
||||
defer stop()
|
||||
@@ -175,12 +210,12 @@ func TestListChannelsOwned(t *testing.T) {
|
||||
11: {"promotions"},
|
||||
12: {},
|
||||
13: {},
|
||||
14: {"main", "chan_self_subscribed", "chan_self_unsub"}, //TODO these two have the interesting cases
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"}, //TODO these two have the interesting cases
|
||||
14: {"main", "chan_self_subscribed", "chan_self_unsub"},
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"},
|
||||
}
|
||||
|
||||
for k, v := range testdata {
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels", data.User[k].UID))
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels?selector=%s", data.User[k].UID, "owned"))
|
||||
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
|
||||
}
|
||||
}
|
||||
@@ -210,12 +245,12 @@ func TestListChannelsSubscribedAny(t *testing.T) {
|
||||
11: {"promotions"},
|
||||
12: {},
|
||||
13: {},
|
||||
14: {"main", "chan_self_subscribed", "chan_self_unsub"}, //TODO these two have the interesting cases
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"}, //TODO these two have the interesting cases
|
||||
14: {"main", "chan_self_subscribed", "chan_other_request", "chan_other_accepted"},
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"},
|
||||
}
|
||||
|
||||
for k, v := range testdata {
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels", data.User[k].UID))
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels?selector=%s", data.User[k].UID, "subscribed_any"))
|
||||
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
|
||||
}
|
||||
}
|
||||
@@ -245,12 +280,12 @@ func TestListChannelsAllAny(t *testing.T) {
|
||||
11: {"promotions"},
|
||||
12: {},
|
||||
13: {},
|
||||
14: {"main", "chan_self_subscribed", "chan_self_unsub"}, //TODO these two have the interesting cases
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"}, //TODO these two have the interesting cases
|
||||
14: {"main", "chan_self_subscribed", "chan_self_unsub", "chan_other_request", "chan_other_accepted"},
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"},
|
||||
}
|
||||
|
||||
for k, v := range testdata {
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels", data.User[k].UID))
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels?selector=%s", data.User[k].UID, "all_any"))
|
||||
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
|
||||
}
|
||||
}
|
||||
@@ -280,12 +315,12 @@ func TestListChannelsSubscribed(t *testing.T) {
|
||||
11: {"promotions"},
|
||||
12: {},
|
||||
13: {},
|
||||
14: {"main", "chan_self_subscribed", "chan_self_unsub"}, //TODO these two have the interesting cases
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"}, //TODO these two have the interesting cases
|
||||
14: {"main", "chan_self_subscribed", "chan_other_accepted"},
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"},
|
||||
}
|
||||
|
||||
for k, v := range testdata {
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels", data.User[k].UID))
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels?selector=%s", data.User[k].UID, "subscribed"))
|
||||
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
|
||||
}
|
||||
}
|
||||
@@ -315,12 +350,12 @@ func TestListChannelsAll(t *testing.T) {
|
||||
11: {"promotions"},
|
||||
12: {},
|
||||
13: {},
|
||||
14: {"main", "chan_self_subscribed", "chan_self_unsub"}, //TODO these two have the interesting cases
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"}, //TODO these two have the interesting cases
|
||||
14: {"main", "chan_self_subscribed", "chan_self_unsub", "chan_other_accepted"},
|
||||
15: {"main", "chan_other_nosub", "chan_other_request", "chan_other_accepted"},
|
||||
}
|
||||
|
||||
for k, v := range testdata {
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels", data.User[k].UID))
|
||||
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/channels?selector=%s", data.User[k].UID, "all"))
|
||||
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,7 +463,9 @@ func doAcceptSub(t *testing.T, baseUrl string, user Userdat, subscriber Userdat,
|
||||
}
|
||||
}
|
||||
|
||||
RequestAuthDelete[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/subscriptions/%v", user.UID, subdat["subscription_id"]), gin.H{})
|
||||
RequestAuthPatch[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/users/%d/subscriptions/%v", user.UID, subdat["subscription_id"]), gin.H{
|
||||
"confirmed": true,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user