Skip to content

Commit 0cc017a

Browse files
committed
Add an integration test.
1 parent a231356 commit 0cc017a

3 files changed

Lines changed: 74 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ jobs:
2727
- name: Build
2828
run: CGO_ENABLED=0 go build
2929

30-
- name: Test
30+
- name: Unit Tests
3131
run: go test -v ./internal/... ./processor/
32+
33+
- name: Integration Test
34+
run: ./rp-connect-python test test.yaml

rot13.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ input:
55
pipeline:
66
processors:
77
- python:
8-
exe: ./venv/bin/python3
8+
exe: python3
99
script: |
1010
import codecs
1111
msg = content().decode()
12-
root = codecs.encode(msg, "rot_13")
12+
root.original = msg
13+
root.encoded = codecs.encode(msg, "rot_13")
1314
1415
output:
1516
stdout: {}

test.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
###############################################################################
2+
# Integration test for rp-connect-python.
3+
#
4+
# Exercises as much surface area as possible to find regressions.
5+
#
6+
###############################################################################
7+
http:
8+
enabled: false
9+
input:
10+
stdin: {}
11+
output:
12+
stdout: {}
13+
14+
pipeline:
15+
processors:
16+
- python:
17+
mode: multi
18+
script: |
19+
# Return a lowercase version.
20+
msg = content().decode()
21+
root = msg.lower()
22+
- python:
23+
mode: legacy
24+
script: |
25+
# Filter to just A-Za-z.
26+
msg = content().decode()
27+
root = "".join([c for c in msg if c.isalpha()])
28+
- python:
29+
mode: single
30+
script: |
31+
# Compute letter frequency and report most common.
32+
letters = content().decode()
33+
34+
freq = {}
35+
for c in letters:
36+
freq.update({c: freq.get(c, 0) + 1})
37+
root.frequency = freq
38+
39+
root.max = 0
40+
root.most = []
41+
for k, v in freq.items():
42+
if v > root.max:
43+
root.most = [k]
44+
root.max = v
45+
elif v == root.max:
46+
root.most.append(k)
47+
48+
tests:
49+
- name: Integration test
50+
target_processors: /pipeline/processors
51+
input_batch:
52+
- content: Hello world!
53+
- content: This page intentionally left blank.
54+
output_batches:
55+
- # Hello world!
56+
- json_equals:
57+
frequency: {"h": 1, "e": 1, "l": 3, "o": 2, "w": 1, "r": 1, "d": 1}
58+
max: 3
59+
most:
60+
- l
61+
# This page intentionally left blank.
62+
- json_contains:
63+
max: 4
64+
most:
65+
- t
66+
- n
67+
- l

0 commit comments

Comments
 (0)