Skip to content

Commit

Permalink
end to end tests
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Smart <[email protected]>
  • Loading branch information
mcred committed Jul 25, 2021
1 parent 11acfd5 commit eee0389
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 1 deletion.
38 changes: 37 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
VERSION=`cat VERSION`
VEXRUN_FILE := $(PWD)/utils/vexrun.jar
VEXRUN := java -jar $(VEXRUN_FILE)

.PHONY: build darwin windows

Expand Down Expand Up @@ -26,4 +28,38 @@ test:
go test -v ./internal/app/... -coverprofile=coverage.out -covermode count

cover: test
go tool cover -html=coverage.out
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

3 changes: 3 additions & 0 deletions internal/app/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions tests/endtoend/add.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]
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
11 changes: 11 additions & 0 deletions tests/endtoend/cleanup.yml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions tests/endtoend/completion.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions tests/endtoend/help.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/endtoend/install.yml
Original file line number Diff line number Diff line change
@@ -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

11 changes: 11 additions & 0 deletions tests/endtoend/list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests:
- "can list installed packages":
command: lpm ls
stdout:
contains:
- Package Category
- ├── [email protected] driver
- ├── [email protected] driver
- ├── [email protected] driver
- ├── [email protected] extension
- └── [email protected] extension
16 changes: 16 additions & 0 deletions tests/endtoend/remove.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions tests/endtoend/search.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
tests:
- "can search all":
command: lpm search
stout:
contains:
- ├── mysql driver
- ├── liquibase-cache extension
- ├── [email protected] 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
1 change: 1 addition & 0 deletions tests/endtoend/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//TODO implement after open source and actual URL is public
7 changes: 7 additions & 0 deletions tests/endtoend/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tests:
- "can get proper version from lpm":
command: lpm --version
stdout: lpm (Liquibase Package Manager) version $VERSION
env:
get:
- VERSION
4 changes: 4 additions & 0 deletions utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

0 comments on commit eee0389

Please sign in to comment.