mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-17 04:30:56 +01:00
added testscript test to test the combination of all tasks
This commit is contained in:
43
t/test-basics.txtar
Normal file
43
t/test-basics.txtar
Normal file
@@ -0,0 +1,43 @@
|
||||
# usage
|
||||
exec tablizer -h
|
||||
stdout Usage
|
||||
|
||||
# version
|
||||
exec tablizer -V
|
||||
stdout version
|
||||
|
||||
# manpage
|
||||
exec tablizer -m
|
||||
stdout SYNOPSIS
|
||||
|
||||
# completion
|
||||
exec tablizer --completion bash
|
||||
stdout __tablizer_init_completion
|
||||
|
||||
# use config (configures colors, but these are not being used, since
|
||||
# this env doesn't support it, but at least it should succeed.
|
||||
exec tablizer -f config.hcl -r testtable.txt Runn
|
||||
stdout Runn
|
||||
|
||||
|
||||
|
||||
# will be automatically created in work dir
|
||||
-- testtable.txt --
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
alertmanager-kube-prometheus-alertmanager-0 2/2 Running 35 (45m ago) 11d
|
||||
grafana-fcc54cbc9-bk7s8 1/1 Running 17 (45m ago) 1d
|
||||
kube-prometheus-blackbox-exporter-5d85b5d8f4-tskh7 1/1 Running 17 (45m ago) 1h44m
|
||||
kube-prometheus-kube-state-metrics-b4cd9487-75p7f 1/1 Running 20 (45m ago) 45m
|
||||
kube-prometheus-node-exporter-bfzpl 1/1 Running 17 (45m ago) 54s
|
||||
|
||||
|
||||
-- config.hcl --
|
||||
BG = "lightGreen"
|
||||
FG = "white"
|
||||
HighlightBG = "lightGreen"
|
||||
HighlightFG = "white"
|
||||
NoHighlightBG = "white"
|
||||
NoHighlightFG = "lightGreen"
|
||||
HighlightHdrBG = "red"
|
||||
HighlightHdrFG = "white"
|
||||
|
||||
26
t/test-csv.txtar
Normal file
26
t/test-csv.txtar
Normal file
@@ -0,0 +1,26 @@
|
||||
# reading from file and matching with lowercase words
|
||||
exec tablizer -c name,status -r testtable.csv -s,
|
||||
stdout grafana.*Runn
|
||||
|
||||
# matching mixed case
|
||||
exec tablizer -c NAME,staTUS -r testtable.csv -s,
|
||||
stdout grafana.*Runn
|
||||
|
||||
# matching using numbers
|
||||
exec tablizer -c 1,3 -r testtable.csv -s,
|
||||
stdout grafana.*Runn
|
||||
|
||||
# matching using regex
|
||||
exec tablizer -c 'na.*,stat.' -r testtable.csv -s,
|
||||
stdout grafana.*Runn
|
||||
|
||||
|
||||
# will be automatically created in work dir
|
||||
-- testtable.csv --
|
||||
NAME,READY,STATUS,RESTARTS,AGE
|
||||
alertmanager-kube-prometheus-alertmanager-0,2/2,Running,35 (45m ago),11d
|
||||
grafana-fcc54cbc9-bk7s8,1/1,Running,17 (45m ago),1d
|
||||
kube-prometheus-blackbox-exporter-5d85b5d8f4-tskh7,1/1,Running,17 (45m ago),1h44m
|
||||
kube-prometheus-kube-state-metrics-b4cd9487-75p7f,1/1,Running,20 (45m ago),45m
|
||||
kube-prometheus-node-exporter-bfzpl,1/1,Running,17 (45m ago),54s
|
||||
|
||||
21
t/test-filtering.txtar
Normal file
21
t/test-filtering.txtar
Normal file
@@ -0,0 +1,21 @@
|
||||
# filtering
|
||||
exec tablizer -r testtable.txt -F name=grafana
|
||||
stdout grafana.*Runn
|
||||
|
||||
# filtering two columns
|
||||
exec tablizer -r testtable.txt -F name=prometh -F age=1h
|
||||
stdout blackbox.*Runn
|
||||
|
||||
# filtering two same columns
|
||||
exec tablizer -r testtable.txt -F name=prometh -F name=alert
|
||||
stdout prometheus-alertmanager.*Runn
|
||||
|
||||
|
||||
# will be automatically created in work dir
|
||||
-- testtable.txt --
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
alertmanager-kube-prometheus-alertmanager-0 2/2 Running 35 (45m ago) 11d
|
||||
grafana-fcc54cbc9-bk7s8 1/1 Running 17 (45m ago) 1d
|
||||
kube-prometheus-blackbox-exporter-5d85b5d8f4-tskh7 1/1 Running 17 (45m ago) 1h44m
|
||||
kube-prometheus-kube-state-metrics-b4cd9487-75p7f 1/1 Running 20 (45m ago) 45m
|
||||
kube-prometheus-node-exporter-bfzpl 1/1 Running 17 (45m ago) 54s
|
||||
25
t/test-headermatching.txtar
Normal file
25
t/test-headermatching.txtar
Normal file
@@ -0,0 +1,25 @@
|
||||
# reading from file and matching with lowercase words
|
||||
exec tablizer -c name,status -r testtable.txt
|
||||
stdout grafana.*Runn
|
||||
|
||||
# matching mixed case
|
||||
exec tablizer -c NAME,staTUS -r testtable.txt
|
||||
stdout grafana.*Runn
|
||||
|
||||
# matching using numbers
|
||||
exec tablizer -c 1,3 -r testtable.txt
|
||||
stdout grafana.*Runn
|
||||
|
||||
# matching using regex
|
||||
exec tablizer -c 'na.*,stat.' -r testtable.txt
|
||||
stdout grafana.*Runn
|
||||
|
||||
|
||||
# will be automatically created in work dir
|
||||
-- testtable.txt --
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
alertmanager-kube-prometheus-alertmanager-0 2/2 Running 35 (45m ago) 11d
|
||||
grafana-fcc54cbc9-bk7s8 1/1 Running 17 (45m ago) 1d
|
||||
kube-prometheus-blackbox-exporter-5d85b5d8f4-tskh7 1/1 Running 17 (45m ago) 1h44m
|
||||
kube-prometheus-kube-state-metrics-b4cd9487-75p7f 1/1 Running 20 (45m ago) 45m
|
||||
kube-prometheus-node-exporter-bfzpl 1/1 Running 17 (45m ago) 54s
|
||||
49
t/test-sort.txtar
Normal file
49
t/test-sort.txtar
Normal file
@@ -0,0 +1,49 @@
|
||||
# sort by name
|
||||
exec tablizer -r testtable.txt -k 1
|
||||
stdout '^alert.*\n^grafana.*\n^kube'
|
||||
|
||||
# sort by name reversed
|
||||
exec tablizer -r testtable.txt -k 1 -D
|
||||
stdout 'kube.*\n^grafana.*\n^alert'
|
||||
|
||||
# sort by starts numerically
|
||||
exec tablizer -r testtable.txt -k 4 -i -c4
|
||||
stdout '17\s*\n^20\s*\n^35'
|
||||
|
||||
# sort by starts numerically reversed
|
||||
exec tablizer -r testtable.txt -k 4 -i -c4 -D
|
||||
stdout '35\s*\n^20\s*\n^17'
|
||||
|
||||
# sort by age
|
||||
exec tablizer -r testtable.txt -k 5 -a
|
||||
stdout '45m\s*\n.*1h44m'
|
||||
|
||||
# sort by age reverse
|
||||
exec tablizer -r testtable.txt -k 5 -a -D
|
||||
stdout '1h44m\s*\n.*45m'
|
||||
|
||||
# sort by time
|
||||
exec tablizer -r timetable.txt -k 2 -t
|
||||
stdout '^sel.*\n^foo.*\nbar'
|
||||
|
||||
# sort by time reverse
|
||||
exec tablizer -r timetable.txt -k 2 -t -D
|
||||
stdout '^bar.*\n^foo.*\nsel'
|
||||
|
||||
|
||||
# will be automatically created in work dir
|
||||
-- testtable.txt --
|
||||
NAME READY STATUS STARTS AGE
|
||||
alertmanager-kube-prometheus-alertmanager-0 2/2 Running 35 11d
|
||||
kube-prometheus-blackbox-exporter-5d85b5d8f4-tskh7 1/1 Running 17 1h44m
|
||||
grafana-fcc54cbc9-bk7s8 1/1 Running 17 1d
|
||||
kube-prometheus-kube-state-metrics-b4cd9487-75p7f 1/1 Running 20 45m
|
||||
kube-prometheus-node-exporter-bfzpl 1/1 Running 17 54s
|
||||
|
||||
|
||||
|
||||
-- timetable.txt --
|
||||
NAME TIME
|
||||
foo 2024-11-18T12:00:00+01:00
|
||||
bar 2024-11-18T12:45:00+01:00
|
||||
sel 2024-07-18T12:00:00+01:00
|
||||
18
t/test-stdin.txtar
Normal file
18
t/test-stdin.txtar
Normal file
@@ -0,0 +1,18 @@
|
||||
# reading from stdin and matching with lowercase words
|
||||
stdin testtable.txt
|
||||
exec tablizer -c name,status
|
||||
stdout grafana.*Runn
|
||||
|
||||
# reading from -r stdin and matching with lowercase words
|
||||
stdin testtable.txt
|
||||
exec tablizer -c name,status -r -
|
||||
stdout grafana.*Runn
|
||||
|
||||
# will be automatically created in work dir
|
||||
-- testtable.txt --
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
alertmanager-kube-prometheus-alertmanager-0 2/2 Running 35 (45m ago) 11d
|
||||
grafana-fcc54cbc9-bk7s8 1/1 Running 17 (45m ago) 1d
|
||||
kube-prometheus-blackbox-exporter-5d85b5d8f4-tskh7 1/1 Running 17 (45m ago) 1h44m
|
||||
kube-prometheus-kube-state-metrics-b4cd9487-75p7f 1/1 Running 20 (45m ago) 45m
|
||||
kube-prometheus-node-exporter-bfzpl 1/1 Running 17 (45m ago) 54s
|
||||
21
t/test-transpose.txtar
Normal file
21
t/test-transpose.txtar
Normal file
@@ -0,0 +1,21 @@
|
||||
# transpose one field
|
||||
exec tablizer -r testtable.txt -T status -R '/Running/OK/'
|
||||
stdout grafana.*OK
|
||||
|
||||
# transpose two fields
|
||||
exec tablizer -r testtable.txt -T name,status -R '/alertmanager-//' -R '/Running/OK/'
|
||||
stdout prometheus-0.*OK
|
||||
|
||||
# transpose one field and show one column
|
||||
exec tablizer -r testtable.txt -T status -R '/Running/OK/' -c name
|
||||
! stdout grafana.*OK
|
||||
|
||||
|
||||
# will be automatically created in work dir
|
||||
-- testtable.txt --
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
alertmanager-kube-prometheus-alertmanager-0 2/2 Running 35 (45m ago) 11d
|
||||
grafana-fcc54cbc9-bk7s8 1/1 Running 17 (45m ago) 1d
|
||||
kube-prometheus-blackbox-exporter-5d85b5d8f4-tskh7 1/1 Running 17 (45m ago) 1h44m
|
||||
kube-prometheus-kube-state-metrics-b4cd9487-75p7f 1/1 Running 20 (45m ago) 45m
|
||||
kube-prometheus-node-exporter-bfzpl 1/1 Running 17 (45m ago) 54s
|
||||
Reference in New Issue
Block a user