mirror of
https://github.com/on4kjm/FLEcli.git
synced 2025-01-18 13:01:09 +01:00
Implement end-to-end tests
This commit is contained in:
parent
dd96badddb
commit
566482744f
8 changed files with 97 additions and 17 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -70,6 +70,8 @@ jobs:
|
|||
uses: goreleaser/goreleaser-action@master
|
||||
with:
|
||||
args: release --snapshot --skip-publish --rm-dist
|
||||
- name: test container
|
||||
run: docker run on4kjm/flecli:latest version -d
|
||||
- name: Setup BATS
|
||||
run: test/install-bats.sh
|
||||
- name: Run End-To_end testing with the docker container
|
||||
run: test/bats/bin/bats test/bats-scripts
|
||||
|
||||
|
|
5
Makefile
5
Makefile
|
@ -5,7 +5,7 @@
|
|||
|
||||
## GITHUB_ACTIONS is set when running as a Github Action
|
||||
|
||||
.PHONY: all lint vet test test-coverage build clean
|
||||
.PHONY: all lint vet test full-test test-coverage build clean
|
||||
|
||||
all: build
|
||||
|
||||
|
@ -22,6 +22,9 @@ vet: ## Run go vet
|
|||
test: ## Run unit tests
|
||||
@go test ./...
|
||||
|
||||
full-test: build ## Run the full end-to-end tests
|
||||
@bats test/bats-scripts
|
||||
|
||||
test-coverage: ## Run tests with coverage
|
||||
@go test -short -coverprofile cover.out -covermode=atomic ./...
|
||||
@cat cover.out >> coverage.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
V2,G3WGV,G/LD-008,24/04/16,1202,7MHz,CW,G4ELZ
|
||||
V2,G3WGV,G/LD-008,24/04/16,1204,7MHz,CW,G3NOH,,PSE QSL Direct
|
||||
V2,G3WGV,G/LD-008,24/04/16,1227,144MHz,FM,GW4GTE
|
||||
V2,G3WGV,G/LD-008,24/04/16,1228,144MHz,FM,GW0TLK/M
|
||||
V2,G3WGV,G/LD-008,03/06/16,1404,7MHz,CW,GM0AAA
|
||||
V2,G3WGV,G/LD-008,03/06/16,1405,7MHz,CW,ON4CK/P,ON/ON-018
|
||||
V2,G3WGV,G/LD-008,03/06/16,1407,7MHz,CW,DL0DAN/P,DL/AL-044
|
||||
V2,G3WGV,G/LD-008,03/06/16,1410,14MHz,CW,YU7LS
|
||||
V2,G3WGV/P,G/LD-008,24/04/16,1202,7MHz,CW,G4ELZ
|
||||
V2,G3WGV/P,G/LD-008,24/04/16,1204,7MHz,CW,G3NOH,,PSE QSL Direct
|
||||
V2,G3WGV/P,G/LD-008,24/04/16,1227,144MHz,FM,GW4GTE
|
||||
V2,G3WGV/P,G/LD-008,24/04/16,1228,144MHz,FM,GW0TLK/M
|
||||
V2,G3WGV/P,G/LD-008,03/06/16,1404,7MHz,CW,GM0AAA
|
||||
V2,G3WGV/P,G/LD-008,03/06/16,1405,7MHz,CW,ON4CK/P,ON/ON-018
|
||||
V2,G3WGV/P,G/LD-008,03/06/16,1407,7MHz,CW,DL0DAN/P,DL/AL-044
|
||||
V2,G3WGV/P,G/LD-008,03/06/16,1410,14MHz,CW,YU7LS
|
||||
|
|
|
41
test/bats-scripts/test.bats
Normal file
41
test/bats-scripts/test.bats
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
# the file is assumed to be run from the root of the project (test data location)
|
||||
|
||||
@test "Does the version show?" {
|
||||
output=$(docker run --rm on4kjm/flecli:latest version -d)
|
||||
echo 'status:' $status
|
||||
echo 'output:' $output
|
||||
}
|
||||
|
||||
|
||||
@test "Can a simple file be loaded?" {
|
||||
output=$(test/docker-FLEcli.sh load -i test/data/fle-1.txt)
|
||||
echo 'status:' $status
|
||||
echo 'output:' $output
|
||||
}
|
||||
|
||||
|
||||
@test "Can a more complex file be loaded?" {
|
||||
output=$(test/docker-FLEcli.sh load -i test/data/ON4KJM@ONFF-025920200524.txt)
|
||||
echo 'status:' $status
|
||||
echo 'output:' $output
|
||||
}
|
||||
|
||||
@test "Is the generated SOTA csv equivalent to the canonical one?" {
|
||||
mkdir -p test/output/temp
|
||||
output=$(test/docker-FLEcli.sh csv -o -i test/FLE-sample/sota_wwff.txt test/output/temp/sota_wwff.csv)
|
||||
echo 'status:' $status
|
||||
echo 'output:' $output
|
||||
diff test/output/temp/sota_wwff.csv test/FLE-sample/sota_wwff.csv --strip-trailing-cr
|
||||
}
|
||||
|
||||
@test "Processing a FLE file with no QSO must fail!" {
|
||||
run test/docker-FLEcli.sh csv -o -i test/data/fle-4-no-qso.txt
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "Processing a FLE file with parsing errors must fail!" {
|
||||
run test/docker-FLEcli.sh csv -o -i test/data/fle-5-wrong-call.txt
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
|
@ -6,3 +6,6 @@
|
|||
|
||||
* `./FLEcli -i test/data/ON4KJM@ONFF-025920200524.txt --interpolate adif --wwff --overwrite`
|
||||
* `./FLEcli adif -i=test/data/ON4KJM@ONFF-025920200524.txt --interpolate --wwff --overwrite`
|
||||
|
||||
|
||||
Install Bats: `brew install bats-core`
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
CURRENT_UID = $(id -u):$(id -g)
|
||||
docker run --rm -ti --user $(CURRENT_UID) -v $(pwd):/FLEcli_data jmmeessen/flecli "$@"
|
||||
CURRENT_UID=$(id -u):$(id -g)
|
||||
docker run --rm -t --user ${CURRENT_UID} -v $(pwd):/FLEcli_data on4kjm/flecli:latest "$@"
|
||||
|
|
30
test/install-bats.sh
Executable file
30
test/install-bats.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
set -eu -o pipefail
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
||||
TMP_DIR=${TMP_DIR:-/tmp}
|
||||
|
||||
## Cleanup
|
||||
rm -rf "${CURRENT_DIR}/bats" "${TMP_DIR}/bats-core"
|
||||
|
||||
## Prepare
|
||||
mkdir -p "${CURRENT_DIR}/helpers"
|
||||
|
||||
cat >"${CURRENT_DIR}/helpers/load.bash" <<EOF
|
||||
#!/bin/bats
|
||||
load "\${BATS_HELPERS_DIR}/bats-support/load.bash"
|
||||
load "\${BATS_HELPERS_DIR}/bats-assert/load.bash"
|
||||
load "\${BATS_HELPERS_DIR}/bats-file/load.bash"
|
||||
load "\${BATS_HELPERS_DIR}/helpers.bash"
|
||||
EOF
|
||||
|
||||
## Install bats from https://github.com/bats-core/bats-core
|
||||
git clone https://github.com/bats-core/bats-core.git "${TMP_DIR}/bats-core"
|
||||
bash "${TMP_DIR}/bats-core/install.sh" "${CURRENT_DIR}/bats"
|
||||
|
||||
## Install bats helper libraries from https://github.com/ztombol/bats-docs
|
||||
for BATS_HELPER in bats-support bats-assert bats-file
|
||||
do
|
||||
git clone "https://github.com/ztombol/${BATS_HELPER}" "${CURRENT_DIR}/helpers/${BATS_HELPER}"
|
||||
rm -rf "${CURRENT_DIR}/helpers/${BATS_HELPER}/.git" # No git tracking
|
||||
done
|
|
@ -4,14 +4,15 @@ set -e
|
|||
|
||||
./build.sh
|
||||
|
||||
mkdir -p test/output/temp
|
||||
|
||||
|
||||
echo "--------------------------"
|
||||
./FLEcli -i test/data/fle-1.txt load
|
||||
./FLEcli load -i test/data/fle-1.txt
|
||||
echo "--------------------------"
|
||||
./FLEcli -i test/data/ON4KJM@ONFF-025920200524.txt load
|
||||
./FLEcli load -i test/data/ON4KJM@ONFF-025920200524.txt
|
||||
echo "--------------------------"
|
||||
./FLEcli -i test/FLE-sample/sota_wwff.txt csv -o=test/output/temp/sota_wwff.csv --interpolate --overwrite
|
||||
mkdir -p test/output/temp
|
||||
./FLEcli csv -o -i test/FLE-sample/sota_wwff.txt test/output/temp/sota_wwff.csv
|
||||
diff test/output/temp/sota_wwff.csv test/FLE-sample/sota_wwff.csv --strip-trailing-cr && echo "no difference" || echo "differences!"
|
||||
echo "--------------------------"
|
||||
./FLEcli -i test/FLE-sample/sota_wwff.txt adif -o=test/output/temp/sota_wwff.adif --interpolate --overwrite --wwff --sota
|
||||
|
|
Loading…
Reference in a new issue