Skip to content

Commit

Permalink
DXCDT-415: Quickstarts integration tests (#693)
Browse files Browse the repository at this point in the history
* Seperating qs tests out, adding cleanup and download test

* Separating qs app script

* Adding quick unit test

---------

Co-authored-by: Will Vedder <[email protected]>
  • Loading branch information
willvedd and willvedd authored Mar 31, 2023
1 parent f08a170 commit e320094
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
5 changes: 0 additions & 5 deletions internal/cli/quickstarts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cli

import (
_ "embed"
"errors"
"fmt"
"os"
"path"
Expand Down Expand Up @@ -355,10 +354,6 @@ func defaultURL(url string, port int) string {
}

func (i *qsInputs) fromArgs(cmd *cobra.Command, args []string, cli *cli) error {
if !canPrompt(cmd) {
return errors.New("this command can only be run on interactive mode")
}

if len(args) == 0 {
if err := qsClientID.Pick(
cmd,
Expand Down
15 changes: 15 additions & 0 deletions internal/cli/quickstarts_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cli

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestQuickstartsTypeFor(t *testing.T) {
assert.Equal(t, qsSpa, quickstartsTypeFor("spa"))
assert.Equal(t, qsWebApp, quickstartsTypeFor("regular_web"))
assert.Equal(t, qsWebApp, quickstartsTypeFor("regular_web"))
assert.Equal(t, qsBackend, quickstartsTypeFor("non_interactive"))
assert.Equal(t, "generic", quickstartsTypeFor("some-unknown-value"))
}
13 changes: 13 additions & 0 deletions test/integration/quickstarts-test-cases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
config:
inherit-env: true
tests:
001 - list quickstarts:
command: auth0 quickstarts list
exit-code: 0
002 - download quickstart:
command: auth0 qs download $(./test/integration/scripts/get-quickstart-app-id.sh) --stack "React Native" --no-color --force
exit-code: 0
stderr:
contains:
- "Quickstart sample successfully downloaded at "
- "Hint: Start with `cd integration-test-app-qs/00-"
13 changes: 13 additions & 0 deletions test/integration/scripts/get-quickstart-app-id.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash

FILE=./test/integration/identifiers/qs-app-id
if [ -f "$FILE" ]; then
cat $FILE
exit 0
fi

app=$( auth0 apps create -n integration-test-app-qs -t native --description "Quickstart app" --json --no-input )

mkdir -p ./test/integration/identifiers
echo "$app" | jq -r '.["client_id"]' > $FILE
cat $FILE
3 changes: 3 additions & 0 deletions test/integration/scripts/test-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,7 @@ auth0 domains delete $(./test/integration/scripts/get-custom-domain-id.sh) --no-
# Reset universal login branding
auth0 ul update --accent "#2A2E35" --background "#FF4F40" --logo "https://example.com/logo.png" --favicon "https://example.com/favicon.png" --font https://example.com/font.woff --no-input

# Removes quickstart directory
rm -rf integration-test-app-qs

rm -rf test/integration/identifiers
3 changes: 0 additions & 3 deletions test/integration/test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ tests:
auth0 rules list:
exit-code: 0

auth0 quickstarts list:
exit-code: 0

auth0 completion bash:
exit-code: 0

Expand Down

0 comments on commit e320094

Please sign in to comment.