forked from raystack/dagger
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for DartDataStoreClientProvider
- Loading branch information
rajuGT
committed
Oct 23, 2024
1 parent
85b6455
commit 5d37d29
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
.../gotocompany/dagger/functions/udfs/scalar/dart/store/DartDataStoreClientProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.gotocompany.dagger.functions.udfs.scalar.dart.store; | ||
|
||
import com.gotocompany.dagger.functions.common.Constants; | ||
import com.gotocompany.dagger.functions.udfs.scalar.dart.store.gcs.GcsDartClient; | ||
import com.gotocompany.dagger.functions.udfs.scalar.dart.store.oss.OssDartClient; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public class DartDataStoreClientProviderTest { | ||
private DartDataStoreClientProvider dartDataStoreClientProvider; | ||
|
||
@Before | ||
public void setUp() { | ||
dartDataStoreClientProvider = null; | ||
} | ||
|
||
@Test | ||
public void shouldReturnGcsDartClientWhenUdfStoreProviderIsGcs() { | ||
String udfStoreProvider = Constants.UDF_STORE_PROVIDER_GCS; | ||
String projectID = "test-project"; | ||
|
||
dartDataStoreClientProvider = new DartDataStoreClientProvider(udfStoreProvider, projectID); | ||
|
||
DartDataStoreClient client = dartDataStoreClientProvider.getDartDataStoreClient(); | ||
|
||
assertTrue(client instanceof GcsDartClient); | ||
} | ||
|
||
@Test | ||
public void shouldReturnOssDartClientWhenUdfStoreProviderIsOss() { | ||
String udfStoreProvider = Constants.UDF_STORE_PROVIDER_OSS; | ||
|
||
dartDataStoreClientProvider = new DartDataStoreClientProvider(udfStoreProvider, null); | ||
DartDataStoreClient client = dartDataStoreClientProvider.getDartDataStoreClient(); | ||
|
||
assertTrue(client instanceof OssDartClient); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void shouldThrowIllegalArgumentExceptionForUnknownUdfStoreProvider() { | ||
String udfStoreProvider = "UNKNOWN-PROVIDER"; | ||
|
||
dartDataStoreClientProvider = new DartDataStoreClientProvider(udfStoreProvider, null); | ||
|
||
try { | ||
dartDataStoreClientProvider.getDartDataStoreClient(); | ||
} catch (IllegalArgumentException e) { | ||
Assert.assertEquals("Unknown UDF Store Provider: UNKNOWN-PROVIDER", e.getMessage()); | ||
throw e; | ||
} | ||
} | ||
|
||
@Test | ||
public void shouldReturnSameClientOnSubsequentCalls() { | ||
String udfStoreProvider = Constants.UDF_STORE_PROVIDER_GCS; | ||
String projectID = "test-project"; | ||
|
||
dartDataStoreClientProvider = new DartDataStoreClientProvider(udfStoreProvider, projectID); | ||
|
||
DartDataStoreClient firstClient = dartDataStoreClientProvider.getDartDataStoreClient(); | ||
DartDataStoreClient secondClient = dartDataStoreClientProvider.getDartDataStoreClient(); | ||
|
||
Assert.assertEquals(firstClient, secondClient); | ||
} | ||
} |