-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
48 additions
and
31 deletions.
There are no files selected for viewing
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
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
13 changes: 13 additions & 0 deletions
13
handlers/sf-datalake-export/src/main/scala/com/gu/sf_datalake_export/util/ExportS3Path.scala
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,13 @@ | ||
package com.gu.sf_datalake_export.util | ||
|
||
import com.gu.effects.{BucketName, S3Path} | ||
import com.gu.sf_datalake_export.handlers.StartJobHandler.ShouldUploadToDataLake | ||
import com.gu.sf_datalake_export.salesforce_bulk_api.BulkApiParams.ObjectName | ||
import com.gu.util.config.Stage | ||
|
||
object ExportS3Path { | ||
def apply(stage: Stage)(objectName: ObjectName, uploadToDataLake: ShouldUploadToDataLake): S3Path = stage match { | ||
case Stage("PROD") if uploadToDataLake.value => S3Path(BucketName(s"ophan-raw-salesforce-customer-data-${objectName.value.toLowerCase}"), None) | ||
case Stage(stageName) => S3Path(BucketName(s"gu-salesforce-export-${stageName.toLowerCase}"), None) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...rs/sf-datalake-export/src/test/scala/com/com/gu/sf_datalake_export/ExportS3PathTest.scala
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,29 @@ | ||
package com.com.gu.sf_datalake_export | ||
|
||
import com.gu.effects.{BucketName, S3Path} | ||
import com.gu.sf_datalake_export.handlers.StartJobHandler.ShouldUploadToDataLake | ||
import com.gu.sf_datalake_export.salesforce_bulk_api.BulkApiParams | ||
import com.gu.sf_datalake_export.util.ExportS3Path | ||
import com.gu.util.config.Stage | ||
import org.scalatest.{FlatSpec, Matchers} | ||
|
||
class ExportS3PathTest extends FlatSpec with Matchers { | ||
"uploadBasePath" should "return ophan bucket basepath for PROD requests with uploadToDataLake enabled" in { | ||
val contactName = BulkApiParams.contact.objectName | ||
val actualBasePath = ExportS3Path(Stage("PROD"))(contactName, ShouldUploadToDataLake(true)) | ||
actualBasePath shouldBe S3Path(BucketName("ophan-raw-salesforce-customer-data-contact"), None) | ||
} | ||
|
||
it should "return test bucket basepath for PROD requests with uploadToDataLake disabled" in { | ||
val contactName = BulkApiParams.contact.objectName | ||
val actualBasePath = ExportS3Path(Stage("PROD"))(contactName, ShouldUploadToDataLake(false)) | ||
actualBasePath shouldBe S3Path(BucketName("gu-salesforce-export-prod"), None) | ||
} | ||
|
||
it should "return test bucket basepath for non PROD requests regardless of the uploadToDataLake param" in { | ||
val contactName = BulkApiParams.contact.objectName | ||
val codeBasePath = ExportS3Path(Stage("CODE"))(contactName, ShouldUploadToDataLake(false)) | ||
val codeBasePathUploadToDl = ExportS3Path(Stage("CODE"))(contactName, ShouldUploadToDataLake(false)) | ||
List(codeBasePath, codeBasePathUploadToDl).distinct shouldBe List(S3Path(BucketName("gu-salesforce-export-code"), None)) | ||
} | ||
} |
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