You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-06-15 00:15:15 +02:00
go fmt
This commit is contained in:
@ -649,7 +649,7 @@ func MockAccount(ctx context.Context, dbConn *sqlx.DB, now time.Time) (*Account,
|
||||
Region: "AK",
|
||||
Country: "USA",
|
||||
Zipcode: "99686",
|
||||
Status: &s,
|
||||
Status: &s,
|
||||
}
|
||||
return Create(ctx, auth.Claims{}, dbConn, req, now)
|
||||
}
|
||||
|
@ -7,12 +7,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/platform/auth"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/platform/tests"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/huandu/go-sqlbuilder"
|
||||
"github.com/lib/pq"
|
||||
"github.com/pborman/uuid"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -38,7 +38,7 @@ func TestAuthenticatorFile(t *testing.T) {
|
||||
error error
|
||||
}{
|
||||
{"NoKeyExpiration", time.Now(), time.Duration(0), nil},
|
||||
{"KeyExpirationOk", time.Now(), time.Duration(time.Second * 3600), nil},
|
||||
{"KeyExpirationOk", time.Now(), time.Duration(time.Second * 3600), nil},
|
||||
{"KeyExpirationDisabled", time.Now().Add(time.Second * 3600 * 3), time.Duration(time.Second * 3600), nil},
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,12 @@ func New() *Test {
|
||||
|
||||
awsSession := session.Must(session.NewSession())
|
||||
|
||||
|
||||
// ============================================================
|
||||
// Startup Postgres container
|
||||
|
||||
var (
|
||||
masterDB *sqlx.DB
|
||||
container *docker.Container
|
||||
masterDB *sqlx.DB
|
||||
container *docker.Container
|
||||
)
|
||||
if !DisableDb {
|
||||
var err error
|
||||
|
@ -7,12 +7,12 @@ import (
|
||||
|
||||
// SignupRequest contains information needed perform signup.
|
||||
type SignupRequest struct {
|
||||
Account account.AccountCreateRequest `json:"account" validate:"required"`
|
||||
User user.UserCreateRequest `json:"user" validate:"required"`
|
||||
Account account.AccountCreateRequest `json:"account" validate:"required"`
|
||||
User user.UserCreateRequest `json:"user" validate:"required"`
|
||||
}
|
||||
|
||||
// SignupResponse contains information needed perform signup.
|
||||
type SignupResponse struct {
|
||||
Account *account.Account `json:"account"`
|
||||
User *user.User `json:"user"`
|
||||
Account *account.Account `json:"account"`
|
||||
User *user.User `json:"user"`
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
"time"
|
||||
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/account"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/platform/auth"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/user"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/user_account"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/platform/auth"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
|
||||
"gopkg.in/go-playground/validator.v9"
|
||||
@ -45,7 +45,7 @@ func Signup(ctx context.Context, claims auth.Claims, dbConn *sqlx.DB, req Signup
|
||||
}
|
||||
|
||||
var uniq bool
|
||||
switch (fl.FieldName()) {
|
||||
switch fl.FieldName() {
|
||||
case "Name":
|
||||
uniq = uniqName
|
||||
case "Email":
|
||||
@ -83,9 +83,9 @@ func Signup(ctx context.Context, claims auth.Claims, dbConn *sqlx.DB, req Signup
|
||||
// Associate the created user with the new account. The first user for the account will
|
||||
// always have the role of admin.
|
||||
ua := user_account.CreateUserAccountRequest{
|
||||
UserID: resp.User.ID,
|
||||
UserID: resp.User.ID,
|
||||
AccountID: resp.Account.ID,
|
||||
Roles: []user_account.UserAccountRole{user_account.UserAccountRole_Admin},
|
||||
Roles: []user_account.UserAccountRole{user_account.UserAccountRole_Admin},
|
||||
//Status: Use default value
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/platform/auth"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/account"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/platform/auth"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/platform/tests"
|
||||
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/user"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/pborman/uuid"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@ -27,7 +27,6 @@ func testMain(m *testing.M) int {
|
||||
return m.Run()
|
||||
}
|
||||
|
||||
|
||||
// TestSignupValidation ensures all the validation tags work on Signup
|
||||
func TestSignupValidation(t *testing.T) {
|
||||
|
||||
@ -43,14 +42,14 @@ func TestSignupValidation(t *testing.T) {
|
||||
return nil
|
||||
},
|
||||
errors.New("Key: 'SignupRequest.Account.Name' Error:Field validation for 'Name' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.Account.Address1' Error:Field validation for 'Address1' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.Account.City' Error:Field validation for 'City' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.Account.Region' Error:Field validation for 'Region' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.Account.Country' Error:Field validation for 'Country' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.Account.Zipcode' Error:Field validation for 'Zipcode' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.User.Name' Error:Field validation for 'Name' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.User.Email' Error:Field validation for 'Email' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.User.Password' Error:Field validation for 'Password' failed on the 'required' tag"),
|
||||
"Key: 'SignupRequest.Account.Address1' Error:Field validation for 'Address1' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.Account.City' Error:Field validation for 'City' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.Account.Region' Error:Field validation for 'Region' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.Account.Country' Error:Field validation for 'Country' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.Account.Zipcode' Error:Field validation for 'Zipcode' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.User.Name' Error:Field validation for 'Name' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.User.Email' Error:Field validation for 'Email' failed on the 'required' tag\n" +
|
||||
"Key: 'SignupRequest.User.Password' Error:Field validation for 'Password' failed on the 'required' tag"),
|
||||
},
|
||||
}
|
||||
|
||||
@ -160,7 +159,6 @@ func TestSignupFull(t *testing.T) {
|
||||
|
||||
t.Logf("\t%s\tSignup ok.", tests.Success)
|
||||
|
||||
|
||||
// Verify that the user can be authenticated with the updated password.
|
||||
_, err = user.Authenticate(ctx, test.MasterDB, tknGen, res.User.Email, req.User.Password, time.Hour, now)
|
||||
if err != nil {
|
||||
|
@ -227,7 +227,6 @@ func generateToken(ctx context.Context, dbConn *sqlx.DB, tknGen TokenGenerator,
|
||||
return Token{Token: tkn, claims: claims}, nil
|
||||
}
|
||||
|
||||
|
||||
// mockTokenGenerator is used for testing that Authenticate calls its provided
|
||||
// token generator in a specific way.
|
||||
type MockTokenGenerator struct {
|
||||
|
Reference in New Issue
Block a user