Skip to content

Commit 9d75539

Browse files
committed
add tests
1 parent 1ebb970 commit 9d75539

File tree

6 files changed

+20
-77
lines changed

6 files changed

+20
-77
lines changed

meltano.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ plugins:
2121
namespace: target_elasticsearch
2222
pip_url: -e .
2323
config:
24-
host: localhost
2524
username: $TARGET_ELASTICSEARCH_USERNAME
2625
password: $TARGET_ELASTICSEARCH_PASSWORD
2726
index_format: "ecs-{{ stream_name }}-an-{{ foo }}-{{ current_timestamp_daily }}"

target_elasticsearch/sinks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import elasticsearch
22
import elasticsearch.helpers
33
import jinja2
4+
import re
45

56
from typing import Optional, Union, Any, Tuple, Set
67

@@ -75,7 +76,7 @@ def _template_index(self, schemas: dict = {}) -> str:
7576
}
7677
environment = jinja2.Environment()
7778
template = environment.from_string(self.config["index_format"])
78-
return template.render(**arguments).replace("_", "-")
79+
return re.sub("[^A-Za-z0-9]+", "", template.render(**arguments).replace("_", "-").lower())
7980

8081
def _build_fields(
8182
self,

tests/integration/__init__.py

Whitespace-only changes.

tests/test_core.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import pytest
2+
import os
3+
from typing import Any
4+
5+
from singer_sdk.testing import get_target_test_class
6+
from target_elasticsearch.target import TargetElasticsearch
7+
8+
SAMPLE_CONFIG: dict[str, Any] = {
9+
"username": "elastic",
10+
"password": os.environ["TARGET_ELASTICSEARCH_PASSWORD"],
11+
}
12+
13+
# Run standard built-in target tests from the SDK:
14+
StandardTargetTests = get_target_test_class(target_class=TargetElasticsearch, config=SAMPLE_CONFIG)
15+
16+
17+
class TestTargetElasticsearch(StandardTargetTests):
18+
"""Test class for TargetElasticsearch."""

tests/unit/__init__.py

Whitespace-only changes.

tests/unit/test_target.py

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)