Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit 2a9f241

Browse files
author
Mateus Moury
committed
test(codec_test): adding tests for error in codec
1 parent 038e284 commit 2a9f241

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/elasticsearch/codec_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ func TestCodec_EncodeElasticRecords_IndexColumn(t *testing.T) {
6464
}
6565
}
6666

67+
func TestCodec_EncodeElasticRecords_InexistentIndexColumn(t *testing.T) {
68+
codec := &basicCodec{
69+
config: Config{IndexColumn: "invalid"},
70+
logger: codecLogger,
71+
}
72+
record, _, _ := fixtures.NewRecord(time.Now())
73+
74+
_, err := codec.EncodeElasticRecords([]*models.Record{record})
75+
assert.Error(t, err)
76+
}
77+
6778
func TestCodec_EncodeElasticRecords_DocIDColumn(t *testing.T) {
6879
codec := &basicCodec{
6980
config: Config{DocIDColumn: "id"},
@@ -77,3 +88,14 @@ func TestCodec_EncodeElasticRecords_DocIDColumn(t *testing.T) {
7788
assert.Equal(t, strconv.Itoa(int(id)), elasticRecord.ID)
7889
}
7990
}
91+
92+
func TestCodec_EncodeElasticRecords_InexistentDocIDColumn(t *testing.T) {
93+
codec := &basicCodec{
94+
config: Config{DocIDColumn: "invalid"},
95+
logger: codecLogger,
96+
}
97+
record, _, _ := fixtures.NewRecord(time.Now())
98+
99+
_, err := codec.EncodeElasticRecords([]*models.Record{record})
100+
assert.Error(t, err)
101+
}

0 commit comments

Comments
 (0)