Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new testing layout #229

Merged
merged 3 commits into from Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions Taskfile.yml
@@ -0,0 +1,23 @@
version: '2'

tasks:
build:
desc: Build the project
cmds:
- go build -v -i

test:
desc: Run the full testsuite
cmds:
- task: test-unit
- task: test-integration

test-unit:
desc: Run unit tests only
cmds:
- go test -short {{ default "-v" .GOFLAGS }} {{ default "./..." .TARGETS }}

test-integration:
desc: Run integration tests only
cmds:
- go test -run Integration {{ default "-v" .GOFLAGS }} {{ default "./..." .TARGETS }}
20 changes: 14 additions & 6 deletions auth/auth_test.go
Expand Up @@ -19,26 +19,34 @@ package auth_test

import (
"encoding/json"
"flag"
"io/ioutil"
"net/http"
"os"
"testing"

"github.com/arduino/arduino-cli/auth"
"github.com/stretchr/testify/require"
)

var (
testUser = os.Getenv("TEST_USERNAME")
testPass = os.Getenv("TEST_PASSWORD")
)

func TestMain(m *testing.M) {
flag.Parse()
os.Exit(m.Run())
func TestNewConfig(t *testing.T) {
conf := auth.New()
require.Equal(t, "https://hydra.arduino.cc/oauth2/auth", conf.CodeURL)
require.Equal(t, "https://hydra.arduino.cc/oauth2/token", conf.TokenURL)
require.Equal(t, "cli", conf.ClientID)
require.Equal(t, "http://localhost:5000", conf.RedirectURI)
require.Equal(t, "profile:core offline", conf.Scopes)
}

func TestToken(t *testing.T) {
func TestTokenIntegration(t *testing.T) {
if testing.Short() {
t.Skip("skip integration test")
}

if testUser == "" || testPass == "" {
t.Skip("Skipped because user and pass were not provided")
}
Expand All @@ -49,7 +57,7 @@ func TestToken(t *testing.T) {
}

// Obtain info
req, err := http.NewRequest("GET", "https://auth.arduino.cc/v1/users/byID/me", nil)
req, err := http.NewRequest("GET", "https://ddauth.arduino.cc/v1/users/byID/me", nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(for context, tests are green because this specific test is skipped on Travis, found out when it was too late)

if err != nil {
t.Fatal(err)
}
Expand Down