Skip to content

Commit

Permalink
test the settings(MPConfig) are not shared between mixpanel instances
Browse files Browse the repository at this point in the history
  • Loading branch information
zihejia committed Jan 21, 2024
1 parent fa3f4a2 commit a181e8d
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,6 @@ public void testSetEnableLogging() throws Exception {
assertFalse(config.DEBUG);
}

@Test
public void testMulptipleConfigs() {
String fakeToken = UUID.randomUUID().toString();
MixpanelAPI mixpanel1 = MixpanelAPI.getInstance(InstrumentationRegistry.getInstrumentation().getContext(), fakeToken, false);
mixpanel1.setServerURL("https://api-eu.mixpanel.com");
assertEquals("https://api-eu.mixpanel.com/track/?ip=1", mixpanel1.getEventEndpoint());

String fakeToken2 = UUID.randomUUID().toString();
MixpanelAPI mixpanel2 = MixpanelAPI.getInstance(InstrumentationRegistry.getInstrumentation().getContext(), fakeToken2, false);
mixpanel2.setServerURL("https://api.mixpanel.com");
assertEquals("https://api.mixpanel.com/track/?ip=1", mixpanel2.getEventEndpoint());
assertEquals("https://api-eu.mixpanel.com/track/?ip=1", mixpanel1.getEventEndpoint());
}

@Test
public void testSetFlushBatchSize() {
Expand All @@ -174,6 +161,22 @@ public void testSetFlushBatchSize2() {
assertEquals(5, mixpanelAPI.getFlushBatchSize());
}

@Test
public void testSetFlushBatchSizeMulptipleConfigs() {
String fakeToken = UUID.randomUUID().toString();
MixpanelAPI mixpanel1 = MixpanelAPI.getInstance(InstrumentationRegistry.getInstrumentation().getContext(), fakeToken, false);
mixpanel1.setFlushBatchSize(10);
assertEquals(10, mixpanel1.getFlushBatchSize());

String fakeToken2 = UUID.randomUUID().toString();
MixpanelAPI mixpanel2 = MixpanelAPI.getInstance(InstrumentationRegistry.getInstrumentation().getContext(), fakeToken2, false);
mixpanel2.setFlushBatchSize(20);
assertEquals(20, mixpanel2.getFlushBatchSize());
// mixpanel2 should not overwrite the settings to mixpanel1
assertEquals(10, mixpanel1.getFlushBatchSize());
}


@Test
public void testSetMaximumDatabaseLimit() {
final Bundle metaData = new Bundle();
Expand Down

0 comments on commit a181e8d

Please sign in to comment.