Skip to content

Commit

Permalink
added test for stringify custom credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Oct 19, 2023
1 parent d1d1de5 commit be0dfa9
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions internal/credentials/unauthenticated_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package credentials
import (
"context"
"errors"
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -36,7 +37,7 @@ func TestUnauthenticatedError(t *testing.T) {
"database:\"/local\"," +
"credentials:\"Anonymous()\"" +
"): test " +
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:27)`", //nolint:lll
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:28)`", //nolint:lll
},
{
err: UnauthenticatedError(
Expand All @@ -51,7 +52,7 @@ func TestUnauthenticatedError(t *testing.T) {
"database:\"/local\"," +
"credentials:\"Anonymous(from:\\\"TestUnauthenticatedError\\\")\"" +
"): test " +
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:42)`", //nolint:lll
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:43)`", //nolint:lll
},
{
err: UnauthenticatedError(
Expand All @@ -66,7 +67,7 @@ func TestUnauthenticatedError(t *testing.T) {
"database:\"/local\"," +
"credentials:\"AccessToken(token:\\\"****(CRC-32c: 9B7801F4)\\\")\"" +
"): test " +
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:57)`", //nolint:lll
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:58)`", //nolint:lll
},
{
err: UnauthenticatedError(
Expand All @@ -81,7 +82,7 @@ func TestUnauthenticatedError(t *testing.T) {
"database:\"/local\"," +
"credentials:\"AccessToken(token:\\\"****(CRC-32c: 9B7801F4)\\\",from:\\\"TestUnauthenticatedError\\\")\"" + //nolint:lll
"): test " +
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:72)`", //nolint:lll
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:73)`", //nolint:lll
},
{
err: UnauthenticatedError(
Expand All @@ -100,7 +101,7 @@ func TestUnauthenticatedError(t *testing.T) {
"database:\"/local\"," +
"credentials:\"Static(user:\\\"USER\\\",password:\\\"SEC**********RD\\\",token:\\\"****(CRC-32c: 00000000)\\\")\"" + //nolint:lll
"): test " +
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:87)`", //nolint:lll
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:88)`", //nolint:lll
},
{
err: UnauthenticatedError(
Expand All @@ -119,7 +120,7 @@ func TestUnauthenticatedError(t *testing.T) {
"database:\"/local\"," +
"credentials:\"Static(user:\\\"USER\\\",password:\\\"SEC**********RD\\\",token:\\\"****(CRC-32c: 00000000)\\\",from:\\\"TestUnauthenticatedError\\\")\"" + //nolint:lll
"): test " +
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:106)`", //nolint:lll
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:107)`", //nolint:lll
},
{
err: UnauthenticatedError(
Expand All @@ -134,7 +135,7 @@ func TestUnauthenticatedError(t *testing.T) {
"database:\"/local\"," +
"credentials:\"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.customCredentials\"" +
"): test " +
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:125)`", //nolint:lll
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:126)`", //nolint:lll
},
{
err: UnauthenticatedError(
Expand All @@ -149,11 +150,15 @@ func TestUnauthenticatedError(t *testing.T) {
"database:\"/local\"," +
"credentials:\"Anonymous()\"" +
"): test " +
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:140)`", //nolint:lll
"at `github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestUnauthenticatedError(unauthenticated_error_test.go:141)`", //nolint:lll
},
} {
t.Run("", func(t *testing.T) {
require.Equal(t, tt.errorString, tt.err.Error())
})
}
}

func TestWrongStringifyCustomCredentials(t *testing.T) {
require.Equal(t, "&{\"SECRET_TOKEN\"}", fmt.Sprintf("%q", &customCredentials{token: "SECRET_TOKEN"}))
}

0 comments on commit be0dfa9

Please sign in to comment.