Unverified Commit 76c233f2 authored by Massimiliano Pippi's avatar Massimiliano Pippi Committed by GitHub

Merge pull request #229 from arduino/massi/test

Introduce new testing layout
parents 10a0cdd3 c5887eef
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 }}
...@@ -19,13 +19,13 @@ package auth_test ...@@ -19,13 +19,13 @@ package auth_test
import ( import (
"encoding/json" "encoding/json"
"flag"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
"testing" "testing"
"github.com/arduino/arduino-cli/auth" "github.com/arduino/arduino-cli/auth"
"github.com/stretchr/testify/require"
) )
var ( var (
...@@ -33,12 +33,20 @@ var ( ...@@ -33,12 +33,20 @@ var (
testPass = os.Getenv("TEST_PASSWORD") testPass = os.Getenv("TEST_PASSWORD")
) )
func TestMain(m *testing.M) { func TestNewConfig(t *testing.T) {
flag.Parse() conf := auth.New()
os.Exit(m.Run()) 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 == "" { if testUser == "" || testPass == "" {
t.Skip("Skipped because user and pass were not provided") t.Skip("Skipped because user and pass were not provided")
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment