Skip to content

Commit

Permalink
Test file source config
Browse files Browse the repository at this point in the history
  • Loading branch information
lazamar committed Dec 13, 2024
1 parent e313f4c commit 34c182d
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ data_sources:
partitioningColumn: aggregate_id

# Connect to a MySQL database
- id: postgres_source
- id: mysql_source
description: Main events store
type: mysql
host: localhost
Expand Down Expand Up @@ -71,6 +71,16 @@ data_sources:
autoIncrementingColumn: id
partitioningColumn: aggregate_id

# Use a plain text file as a data source.
# Each line must be a valid JSON object.
# Values are projected as they are added.
- id: file_source
description: My file JSON event store
type: file
path: ./path/to/source.file
incrementingField: id
partitioningField: aggregate_id

# Connections to your endpoint.
# The Emulator will send data read from the databases to these endpoints.
data_destinations:
Expand Down
12 changes: 11 additions & 1 deletion examples/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data_sources:
partitioningColumn: aggregate_id

# Connect to a MySQL database
- id: postgres_source
- id: mysql_source
description: Main events store
type: mysql
host: localhost
Expand Down Expand Up @@ -56,6 +56,16 @@ data_sources:
autoIncrementingColumn: id
partitioningColumn: aggregate_id

# Use a plain text file as a data source.
# Each line must be a valid JSON object.
# Values are projected as they are added.
- id: file_source
description: My file JSON event store
type: file
path: ./path/to/source.file
incrementingField: id
partitioningField: aggregate_id

# Connections to your endpoint.
# The Emulator will send data read from the databases to these endpoints.
data_destinations:
Expand Down
48 changes: 47 additions & 1 deletion tests/Test/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,42 @@ testConfig = do
description: The file source
type: file
path: ./source.txt
incrementingField: id
partitioningField: aggregate_id

- id: mysql_source
description: Main events store
type: mysql
host: localhost
port: 5432
username: my_user
password: my_pass
database: my_db
table: events_table
columns:
- id
- aggregate_id
- sequence_number
- payload
autoIncrementingColumn: id
partitioningColumn: aggregate_id

- id: sqlserver_source
description: Main events store
type: sqlserver
host: localhost
port: 1433
username: my_user
password: my_pass
database: my_db
table: events_table
columns:
- id
- aggregate_id
- sequence_number
- payload
autoIncrementingColumn: id
partitioningColumn: aggregate_id

data_destinations:
- id: file_destination
Expand All @@ -55,6 +91,8 @@ testConfig = do
sources:
- postgres_source
- file_source
- mysql_source
- sqlserver_source

- id: HTTP_destination
description: my projection 2
Expand All @@ -66,8 +104,10 @@ testConfig = do
sources:
- postgres_source
- file_source
- mysql_source
- sqlserver_source
|]
annotate "source count" $ Map.size (c_sources config) `shouldBe` 2
annotate "source count" $ Map.size (c_sources config) `shouldBe` 4
annotate "source count" $ Map.size (c_destinations config) `shouldBe` 2

it "detects duplicate sources" $ do
Expand All @@ -77,11 +117,15 @@ testConfig = do
description: The file source
type: file
path: ./source.txt
incrementingField: id
partitioningField: aggregate_id

- id: source_1
description: The file source
type: file
path: ./source.txt
incrementingField: id
partitioningField: aggregate_id

data_destinations:
- id: file_destination
Expand All @@ -100,6 +144,8 @@ testConfig = do
description: The file source
type: file
path: ./source.txt
incrementingField: id
partitioningField: aggregate_id

data_destinations:
- id: dest_1
Expand Down

0 comments on commit 34c182d

Please sign in to comment.