Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Feb 27, 2024
1 parent 11adbe2 commit 5d73a8d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/test/java/io/supertokens/test/TelemetryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import io.supertokens.cronjobs.telemetry.Telemetry;
import io.supertokens.dashboard.Dashboard;
import io.supertokens.httpRequest.HttpRequestMocking;
import io.supertokens.pluginInterface.STORAGE_TYPE;
import io.supertokens.storageLayer.StorageLayer;
import io.supertokens.test.TestingProcessManager.TestingProcess;
import io.supertokens.version.Version;
import org.junit.AfterClass;
Expand Down Expand Up @@ -115,8 +117,9 @@ public void testThatTelemetryWorks() throws Exception {
process.startProcess();
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED));

Dashboard.signUpDashboardUser(process.getProcess(), "[email protected]", "password123");

if (StorageLayer.getBaseStorage(process.getProcess()).getType() == STORAGE_TYPE.SQL) {
Dashboard.signUpDashboardUser(process.getProcess(), "[email protected]", "password123");
}
// Restarting the process to send telemetry again
process.kill(false);
process = TestingProcessManager.start(args, false);
Expand Down Expand Up @@ -167,9 +170,17 @@ protected URLConnection openConnection(URL u) {
assertEquals(telemetryData.get("connectionUriDomain").getAsString(), "");
assertTrue(telemetryData.has("maus"));
assertTrue(telemetryData.has("dashboardUserEmails"));
assertEquals(1, telemetryData.get("dashboardUserEmails").getAsJsonArray().size());
assertEquals("[email protected]", telemetryData.get("dashboardUserEmails").getAsJsonArray().get(0).getAsString());
assertEquals(31, telemetryData.get("maus").getAsJsonArray().size());

if (StorageLayer.getBaseStorage(process.getProcess()).getType() == STORAGE_TYPE.SQL) {
assertEquals(1, telemetryData.get("dashboardUserEmails").getAsJsonArray().size());
assertEquals("[email protected]", telemetryData.get("dashboardUserEmails").getAsJsonArray().get(0).getAsString());
assertEquals(31, telemetryData.get("maus").getAsJsonArray().size());
assertEquals(0, telemetryData.get("usersCount").getAsInt());
} else {
assertEquals(0, telemetryData.get("dashboardUserEmails").getAsJsonArray().size());
assertEquals(0, telemetryData.get("maus").getAsJsonArray().size());
assertEquals(-1, telemetryData.get("usersCount").getAsInt());
}

process.kill();
assertNotNull(process.checkOrWaitForEvent(PROCESS_STATE.STOPPED));
Expand Down

0 comments on commit 5d73a8d

Please sign in to comment.