From eee0389de80b4ec17af787a344f06ecccd4971b7 Mon Sep 17 00:00:00 2001 From: Derek Smart Date: Sat, 24 Jul 2021 23:33:15 -0400 Subject: [PATCH] end to end tests Signed-off-by: Derek Smart --- Makefile | 38 ++++++++++++++++++++++++++++++++++- internal/app/commands/add.go | 3 +++ tests/endtoend/add.yml | 22 ++++++++++++++++++++ tests/endtoend/cleanup.yml | 11 ++++++++++ tests/endtoend/completion.yml | 27 +++++++++++++++++++++++++ tests/endtoend/help.yml | 17 ++++++++++++++++ tests/endtoend/install.yml | 15 ++++++++++++++ tests/endtoend/list.yml | 11 ++++++++++ tests/endtoend/remove.yml | 16 +++++++++++++++ tests/endtoend/search.yml | 29 ++++++++++++++++++++++++++ tests/endtoend/update.yml | 1 + tests/endtoend/version.yml | 7 +++++++ utils/.gitignore | 4 ++++ 13 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 tests/endtoend/add.yml create mode 100644 tests/endtoend/cleanup.yml create mode 100644 tests/endtoend/completion.yml create mode 100644 tests/endtoend/help.yml create mode 100644 tests/endtoend/install.yml create mode 100644 tests/endtoend/list.yml create mode 100644 tests/endtoend/remove.yml create mode 100644 tests/endtoend/search.yml create mode 100644 tests/endtoend/update.yml create mode 100644 tests/endtoend/version.yml create mode 100644 utils/.gitignore diff --git a/Makefile b/Makefile index 8c0954b..e59179c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ VERSION=`cat VERSION` +VEXRUN_FILE := $(PWD)/utils/vexrun.jar +VEXRUN := java -jar $(VEXRUN_FILE) .PHONY: build darwin windows @@ -26,4 +28,38 @@ test: go test -v ./internal/app/... -coverprofile=coverage.out -covermode count cover: test - go tool cover -html=coverage.out \ No newline at end of file + go tool cover -html=coverage.out + +test-setup: + curl -Ls https://github.com/mcred/vexrun/releases/download/v0.0.5/vexrun-0.0.5.jar -z $(VEXRUN_FILE) -o $(VEXRUN_FILE) + +e2e: test-version test-add test-completion test-help test-install test-list test-remove test-search test-cleanup + +test-cleanup: + -rm -Rf $(PWD)/liquibase_modules + -rm $(PWD)/liquibase.json + +test-version: + $(VEXRUN) -f $(PWD)/tests/endtoend/version.yml -p VERSION $(VERSION) + +test-add: + $(VEXRUN) -f $(PWD)/tests/endtoend/add.yml + +test-completion: + $(VEXRUN) -f $(PWD)/tests/endtoend/completion.yml + +test-help: + $(VEXRUN) -f $(PWD)/tests/endtoend/help.yml + +test-install: + $(VEXRUN) -f $(PWD)/tests/endtoend/install.yml + +test-list: + $(VEXRUN) -f $(PWD)/tests/endtoend/list.yml + +test-remove: + $(VEXRUN) -f $(PWD)/tests/endtoend/remove.yml + +test-search: + $(VEXRUN) -f $(PWD)/tests/endtoend/search.yml + diff --git a/internal/app/commands/add.go b/internal/app/commands/add.go index 7179518..cef8bf9 100644 --- a/internal/app/commands/add.go +++ b/internal/app/commands/add.go @@ -21,6 +21,9 @@ var addCmd = &cobra.Command{ app.SetClasspath(global, globalpath, globalpathFiles) d := dependencies.Dependencies{} + if !global { + d.Read() + } for _, name := range args { var p packages.Package diff --git a/tests/endtoend/add.yml b/tests/endtoend/add.yml new file mode 100644 index 0000000..38ae636 --- /dev/null +++ b/tests/endtoend/add.yml @@ -0,0 +1,22 @@ +tests: + - "can add one package": + command: lpm add liquibase-postgresql + stdout: + contains: liquibase-postgresql-4.4.1.jar successfully installed in classpath. + - "verify one package": + command: stat ./liquibase_modules/liquibase-postgresql-4.4.1.jar + - "can add multi packages": + command: lpm add postgresql mysql mssql + stdout: + contains: + - postgresql-42.2.23.jar successfully installed in classpath. + - mysql-connector-java-8.0.25.jar successfully installed in classpath. + - mssql-jdbc-9.2.1.jre11.jar successfully installed in classpath. + - "verify multi packages": + command: stat ./liquibase_modules/mssql-jdbc-9.2.1.jre11.jar + - "can add specific version": + command: lpm add liquibase-percona@4.3.1 + stdout: + contains: liquibase-percona-4.3.1.jar successfully installed in classpath. + - "verify specific version": + command: stat ./liquibase_modules/liquibase-percona-4.3.1.jar \ No newline at end of file diff --git a/tests/endtoend/cleanup.yml b/tests/endtoend/cleanup.yml new file mode 100644 index 0000000..fd13183 --- /dev/null +++ b/tests/endtoend/cleanup.yml @@ -0,0 +1,11 @@ +tests: + - "can run clean liquibase_modules": + command: rm -Rf $PWD/liquibase_modules + env: + get: + - PWD + - "can remove liquibase.json": + command: rm liquibase.json + env: + get: + - PWD \ No newline at end of file diff --git a/tests/endtoend/completion.yml b/tests/endtoend/completion.yml new file mode 100644 index 0000000..d8a7ba7 --- /dev/null +++ b/tests/endtoend/completion.yml @@ -0,0 +1,27 @@ +tests: + - "can generate bash completion": + command: lpm completion bash + stdout: + contains: + - bash completion V2 for lpm + - __lpm_handle_standard_completion_case() + - "can generate zfs completion": + command: lpm completion zsh + stdout: + contains: + - zsh completion for lpm + - __lpm_debug() + - "can generate fish completion": + command: lpm completion fish + stdout: + contains: + - fish completion for lpm + - function __lpm_debug + - function __lpm_perform_completion + - "can generate powershell completion": + command: lpm completion powershell + stdout: + contains: + - powershell completion for lpm + - function __lpm_debug + - Register-ArgumentCompleter -CommandName 'lpm' -ScriptBlock \ No newline at end of file diff --git a/tests/endtoend/help.yml b/tests/endtoend/help.yml new file mode 100644 index 0000000..2267efb --- /dev/null +++ b/tests/endtoend/help.yml @@ -0,0 +1,17 @@ +tests: + - "can get help output": + command: lpm --help + stdout: + contains: + - Easily manage external dependencies for Database Development. + - Search for, install, and uninstall liquibase drivers, extensions, and utilities. + - lpm [command] + - add Add Packages + - completion generate the autocompletion script for the specified shell + - help Help about any command + - install Install Packages from liquibase.json + - list List Installed Packages + - remove Removes Package + - search Search for Packages + - update Updates the Package Manifest + - --category string extension, driver, or utility \ No newline at end of file diff --git a/tests/endtoend/install.yml b/tests/endtoend/install.yml new file mode 100644 index 0000000..bb882d2 --- /dev/null +++ b/tests/endtoend/install.yml @@ -0,0 +1,15 @@ +tests: + - "can remove installed packages": + command: rm -Rf ./liquibase_modules + - "can install packages from liquibase.json": + command: lpm install + - "verify installed packages": + command: stat ./liquibase_modules/liquibase-percona-4.3.1.jar ./liquibase_modules/postgresql-42.2.23.jar ./liquibase_modules/mssql-jdbc-9.2.1.jre11.jar ./liquibase_modules/mysql-connector-java-8.0.25.jar ./liquibase_modules/liquibase-postgresql-4.4.1.jar + stdout: + contains: + - ./liquibase_modules/liquibase-percona-4.3.1.jar + - ./liquibase_modules/postgresql-42.2.23.jar + - ./liquibase_modules/mssql-jdbc-9.2.1.jre11.jar + - ./liquibase_modules/mysql-connector-java-8.0.25.jar + - ./liquibase_modules/liquibase-postgresql-4.4.1.jar + diff --git a/tests/endtoend/list.yml b/tests/endtoend/list.yml new file mode 100644 index 0000000..d0392cf --- /dev/null +++ b/tests/endtoend/list.yml @@ -0,0 +1,11 @@ +tests: + - "can list installed packages": + command: lpm ls + stdout: + contains: + - Package Category + - ├── postgresql@42.2.23 driver + - ├── mssql@9.2.1 driver + - ├── mysql@8.0.25 driver + - ├── liquibase-percona@4.3.1 extension + - └── liquibase-postgresql@4.4.1 extension diff --git a/tests/endtoend/remove.yml b/tests/endtoend/remove.yml new file mode 100644 index 0000000..66c472d --- /dev/null +++ b/tests/endtoend/remove.yml @@ -0,0 +1,16 @@ +tests: + - "can remove one package": + command: lpm remove postgresql + stdout: postgresql-42.2.23.jar successfully uninstalled from classpath. + - "verify one package removed": + command: stat ./liquibase_modules/postgresql-42.2.23.jar + exitValue: 1 + - "can remove multi packages": + command: lpm rm mssql mysql liquibase-percona + stdout: |- + mssql-jdbc-9.2.1.jre11.jar successfully uninstalled from classpath. + mysql-connector-java-8.0.25.jar successfully uninstalled from classpath. + liquibase-percona-4.3.1.jar successfully uninstalled from classpath. + - "verify multi packages removed": + command: stat ./liquibase_modules/mssql-jdbc-9.2.1.jre11.jar ./liquibase_modules/mysql-connector-java-8.0.25.jar ./liquibase_modules/liquibase-percona-4.3.1.jar + exitValue: 1 \ No newline at end of file diff --git a/tests/endtoend/search.yml b/tests/endtoend/search.yml new file mode 100644 index 0000000..adf3650 --- /dev/null +++ b/tests/endtoend/search.yml @@ -0,0 +1,29 @@ +tests: + - "can search all": + command: lpm search + stout: + contains: + - ├── mysql driver + - ├── liquibase-cache extension + - ├── liquibase-postgresql@4.4.1 extension + - "can search drivers": + command: [lpm, search, --category, driver] + stdout: + contains: + - ├── mssql driver + excludes: + - ├── liquibase-cache extension + - "can search extensions": + command: [lpm, search, --category, extension] + stdout: + contains: ├── liquibase-cache extension + excludes: ├── mysql driver + - "can search by term": + command: lpm search sql + stdout: + contains: + - ├── liquibase-mssql extension + - ├── sqlite driver + excludes: + - ├── liquibase-teradata extension + - ├── mariadb driver \ No newline at end of file diff --git a/tests/endtoend/update.yml b/tests/endtoend/update.yml new file mode 100644 index 0000000..e7f0e54 --- /dev/null +++ b/tests/endtoend/update.yml @@ -0,0 +1 @@ +//TODO implement after open source and actual URL is public \ No newline at end of file diff --git a/tests/endtoend/version.yml b/tests/endtoend/version.yml new file mode 100644 index 0000000..70773d1 --- /dev/null +++ b/tests/endtoend/version.yml @@ -0,0 +1,7 @@ +tests: + - "can get proper version from lpm": + command: lpm --version + stdout: lpm (Liquibase Package Manager) version $VERSION + env: + get: + - VERSION \ No newline at end of file diff --git a/utils/.gitignore b/utils/.gitignore new file mode 100644 index 0000000..86d0cb2 --- /dev/null +++ b/utils/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file