From 36425657bf0bc9ebcd5f0785106a1fd26d912690 Mon Sep 17 00:00:00 2001 From: Claudson Oliveira Date: Tue, 13 Oct 2020 18:01:54 +0100 Subject: [PATCH] Add support to functional tests #92 (#108) Include a low number of tests. --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ main.go | 1 + tests/options.bats | 26 ++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/options.bats diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea0cb04..7ac5248 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,11 @@ jobs: with: go-version: 1.12 id: go + + - name: Setup BATS + uses: mig4/setup-bats@v1.0.1 + with: + bats-version: 1.1.0 - name: Check out code into the Go module directory uses: actions/checkout@v1 @@ -30,6 +35,10 @@ jobs: run: | go build . ./gitql -v + + - name: Run function tests + run: bats --tap ./tests + - uses: actions/upload-artifact@master name: Generating artifact with: @@ -45,6 +54,11 @@ jobs: with: go-version: 1.12 id: go + + - name: Setup BATS + uses: mig4/setup-bats@v1.0.1 + with: + bats-version: 1.1.0 - name: Check out code into the Go module directory uses: actions/checkout@v1 @@ -59,6 +73,10 @@ jobs: run: | go build . ./gitql -v + + - name: Run function tests + run: bats --tap ./tests + - uses: actions/upload-artifact@master name: Generating artifact with: @@ -75,6 +93,11 @@ jobs: go-version: 1.12 id: go + - name: Setup BATS + uses: mig4/setup-bats@v1.0.1 + with: + bats-version: 1.1.0 + - name: Check out code into the Go module directory uses: actions/checkout@v1 @@ -87,6 +110,9 @@ jobs: go build . .\gitql.exe -v + - name: Run function tests + run: bats --tap ./tests + - uses: actions/upload-artifact@master name: Generating artifact with: diff --git a/main.go b/main.go index 69d1705..a70f672 100644 --- a/main.go +++ b/main.go @@ -50,6 +50,7 @@ func main() { }, &cli.BoolFlag{ Name: "show-tables", + Aliases: []string{"s"}, Hidden: true, }, }, diff --git a/tests/options.bats b/tests/options.bats new file mode 100644 index 0000000..cc225ef --- /dev/null +++ b/tests/options.bats @@ -0,0 +1,26 @@ +#!/usr/bin/env bats + +@test "Check version" { + result="$(./gitql -v)" + [ "$result" == "Gitql 2.1.0" ] +} + +@test "Check table commits on -s" { + result="$(./gitql -s | grep commits)" + [ "$result" == "commits" ] +} + +@test "Check table refs on -s" { + result="$(./gitql -s | grep refs)" + [ "$result" == "refs" ] +} + +@test "Check table tags on -s" { + result="$(./gitql -s | grep tags)" + [ "$result" == "tags" ] +} + +@test "Check table branches on -s" { + result="$(./gitql -s | grep branches)" + [ "$result" == "branches" ] +}