diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 00000000000..9cf78a338ba --- /dev/null +++ b/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 }} diff --git a/auth/auth_test.go b/auth/auth_test.go index 6a17655851e..842f782df98 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -19,13 +19,13 @@ 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 ( @@ -33,12 +33,20 @@ var ( 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") }