Skip to content

Commit cd50e79

Browse files
authored
fix: Add stringer to Token (#71)
1 parent e6160a0 commit cd50e79

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

auth/token.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package auth
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/cloudquery/cloudquery-api-go/config"
76
"io"
87
"net/http"
98
"net/url"
109
"os"
1110
"time"
11+
12+
"github.com/cloudquery/cloudquery-api-go/config"
1213
)
1314

1415
const (
@@ -44,6 +45,10 @@ type Token struct {
4445
Value string
4546
}
4647

48+
func (t Token) String() string {
49+
return t.Value
50+
}
51+
4752
type TokenClient struct {
4853
url string
4954
apiKey string

auth/token_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package auth
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/stretchr/testify/require"
76
"net/http"
87
"net/http/httptest"
98
"os"
109
"testing"
1110
"time"
11+
12+
"github.com/stretchr/testify/require"
1213
)
1314

1415
func TestRefreshToken_RoundTrip(t *testing.T) {
@@ -39,6 +40,12 @@ func TestRefreshToken_Removal(t *testing.T) {
3940
require.Error(t, err)
4041
}
4142

43+
func TestToken_Stringer(t *testing.T) {
44+
token := Token{Type: BearerToken, Value: "my_token"}
45+
out := fmt.Sprintf("Bearer %s", token)
46+
require.Equal(t, "Bearer my_token", out)
47+
}
48+
4249
func TestTokenClient_EnvironmentVariable(t *testing.T) {
4350
reset := overrideEnvironmentVariable(t, EnvVarCloudQueryAPIKey, "my_token")
4451
defer reset()

0 commit comments

Comments
 (0)