Skip to content

Commit dc72008

Browse files
committed
define test as integration, add unit test case
1 parent 10a0cdd commit dc72008

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

auth/auth_test.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,34 @@ package auth_test
1919

2020
import (
2121
"encoding/json"
22-
"flag"
2322
"io/ioutil"
2423
"net/http"
2524
"os"
2625
"testing"
2726

2827
"github.com/arduino/arduino-cli/auth"
28+
"github.com/stretchr/testify/require"
2929
)
3030

3131
var (
3232
testUser = os.Getenv("TEST_USERNAME")
3333
testPass = os.Getenv("TEST_PASSWORD")
3434
)
3535

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

41-
func TestToken(t *testing.T) {
45+
func TestTokenIntegration(t *testing.T) {
46+
if testing.Short() {
47+
t.Skip("skip integration test")
48+
}
49+
4250
if testUser == "" || testPass == "" {
4351
t.Skip("Skipped because user and pass were not provided")
4452
}
@@ -49,7 +57,7 @@ func TestToken(t *testing.T) {
4957
}
5058

5159
// Obtain info
52-
req, err := http.NewRequest("GET", "https://auth.arduino.cc/v1/users/byID/me", nil)
60+
req, err := http.NewRequest("GET", "https://ddauth.arduino.cc/v1/users/byID/me", nil)
5361
if err != nil {
5462
t.Fatal(err)
5563
}

0 commit comments

Comments
 (0)