Skip to content

Commit

Permalink
✅ fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zcubbs committed Aug 20, 2023
1 parent 07c3625 commit f4b0357
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions api/main_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package api

import (
"context"
"fmt"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
db "github.com/zcubbs/tlz/db/sqlc"
"github.com/zcubbs/tlz/internal/util"
"github.com/zcubbs/tlz/pkg/random"
"github.com/zcubbs/tlz/pkg/token"
"github.com/zcubbs/tlz/worker"
"google.golang.org/grpc/metadata"
"testing"
"time"
)
Expand All @@ -30,16 +25,16 @@ func newTestServer(t *testing.T, store db.Store, taskDistributor worker.TaskDist
return server
}

func newContextWithBearerToken(t *testing.T, tokenMaker token.Maker, username string, userId uuid.UUID, duration time.Duration) context.Context {
accessToken, _, err := tokenMaker.CreateToken(username, userId, duration)
require.NoError(t, err)

bearerToken := fmt.Sprintf("%s %s", authorizationBearer, accessToken)
md := metadata.MD{
authorizationHeader: []string{
bearerToken,
},
}

return metadata.NewIncomingContext(context.Background(), md)
}
//func newContextWithBearerToken(t *testing.T, tokenMaker token.Maker, username string, userId uuid.UUID, duration time.Duration) context.Context {
// accessToken, _, err := tokenMaker.CreateToken(username, userId, duration)
// require.NoError(t, err)
//
// bearerToken := fmt.Sprintf("%s %s", authorizationBearer, accessToken)
// md := metadata.MD{
// authorizationHeader: []string{
// bearerToken,
// },
// }
//
// return metadata.NewIncomingContext(context.Background(), md)
//}

0 comments on commit f4b0357

Please sign in to comment.