From ff24493ff353050f0ba3f361c9f5c26afbd14a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Tue, 17 Jan 2023 20:27:20 +0100 Subject: [PATCH] Tests[CompatRegister, CompatInfo] --- scnserver/test/compat_test.go | 67 +++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/scnserver/test/compat_test.go b/scnserver/test/compat_test.go index 55db570..551dd18 100644 --- a/scnserver/test/compat_test.go +++ b/scnserver/test/compat_test.go @@ -193,22 +193,6 @@ func TestSendCompatWithNewUser(t *testing.T) { } -func TestCreateCompatUser(t *testing.T) { - _, baseUrl, stop := tt.StartSimpleWebserver(t) - defer stop() - - r0 := tt.RequestGet[gin.H](t, baseUrl, fmt.Sprintf("/api/register.php?fcm_token=%s&pro=%s&pro_token=%s", "DUMMY_FCM", "0", "")) - - tt.AssertEqual(t, "success", true, r0["success"]) - - userid := int64(r0["user_id"].(float64)) - userkey := r0["user_key"].(string) - - r1 := tt.RequestGet[gin.H](t, baseUrl, fmt.Sprintf("/api/info.php?user_id=%d&user_key=%s", userid, userkey)) - - tt.AssertEqual(t, "success", true, r1["success"]) -} - func TestSendCompatMessageByQuery(t *testing.T) { _, baseUrl, stop := tt.StartSimpleWebserver(t) defer stop() @@ -318,6 +302,53 @@ func TestSendCompatMessageByFormData(t *testing.T) { tt.AssertEqual(t, "suppress_send", true, r3["suppress_send"]) } -//TODO test compat methods +func TestCompatRegister(t *testing.T) { + _, baseUrl, stop := tt.StartSimpleWebserver(t) + defer stop() -//TODO also test compat_id mapping + r0 := tt.RequestGet[gin.H](t, baseUrl, fmt.Sprintf("/api/register.php?fcm_token=%s&pro=%s&pro_token=%s", "DUMMY_FCM", "0", "")) + tt.AssertEqual(t, "success", true, r0["success"]) +} + +func TestCompatInfo(t *testing.T) { + _, baseUrl, stop := tt.StartSimpleWebserver(t) + defer stop() + + r0 := tt.RequestGet[gin.H](t, baseUrl, fmt.Sprintf("/api/register.php?fcm_token=%s&pro=%s&pro_token=%s", "DUMMY_FCM", "0", "")) + tt.AssertEqual(t, "success", true, r0["success"]) + + userid := int64(r0["user_id"].(float64)) + userkey := r0["user_key"].(string) + + r1 := tt.RequestGet[gin.H](t, baseUrl, fmt.Sprintf("/api/info.php?user_id=%d&user_key=%s", userid, userkey)) + + tt.AssertEqual(t, "success", true, r1["success"]) + tt.AssertEqual(t, "fcm_token_set", true, r1["fcm_token_set"]) + tt.AssertEqual(t, "is_pro", 0, int(r1["is_pro"].(float64))) + tt.AssertEqual(t, "message", "ok", r1["message"]) + tt.AssertEqual(t, "quota", 0, int(r1["quota"].(float64))) + tt.AssertEqual(t, "quota_max", 50, int(r1["quota_max"].(float64))) + tt.AssertEqual(t, "unack_count", 0, int(r1["unack_count"].(float64))) + tt.AssertEqual(t, "user_id", userid, int64(r1["user_id"].(float64))) + tt.AssertEqual(t, "user_key", userkey, r1["user_key"].(string)) +} + +func TestCompatAck(t *testing.T) { + t.SkipNow() //TODO +} + +func TestCompatRequery(t *testing.T) { + t.SkipNow() //TODO +} + +func TestCompatUpdate(t *testing.T) { + t.SkipNow() //TODO +} + +func TestCompatExpand(t *testing.T) { + t.SkipNow() //TODO +} + +func TestCompatUpgrade(t *testing.T) { + t.SkipNow() //TODO +}