Skip to content

Commit

Permalink
add get bucket region test and move tests to their respective package…
Browse files Browse the repository at this point in the history
… for private function/method testing
  • Loading branch information
Akopti8 committed Jun 25, 2024
1 parent 517d19f commit 36ff6fb
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/s3api-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: go get -v -t -d ./...

- name: Run Tests
run: go test -tags=test -v ./test/s3controller_test.go
run: go test ./auth ./blobstore -tags=test -v
15 changes: 7 additions & 8 deletions test/auth_database_test.go → auth/auth_database_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
//go:build test
// +build test

package test
package auth

import (
"database/sql"
"regexp"
"testing"

"github.com/DATA-DOG/go-sqlmock"
"github.com/Dewberry/s3api/auth"
"github.com/lib/pq"
"github.com/stretchr/testify/require"
)
Expand All @@ -19,7 +18,7 @@ func TestCheckUserPermission(t *testing.T) {
require.NoError(t, err)
defer db.Close()

pgDB := &auth.PostgresDB{Handle: db}
pgDB := &PostgresDB{Handle: db}

userEmail := "[email protected]"
bucket := "test-bucket"
Expand Down Expand Up @@ -50,7 +49,7 @@ func TestCheckUserPermissionError(t *testing.T) {
require.NoError(t, err)
defer db.Close()

pgDB := &auth.PostgresDB{Handle: db}
pgDB := &PostgresDB{Handle: db}

userEmail := "[email protected]"
bucket := "test-bucket"
Expand Down Expand Up @@ -81,7 +80,7 @@ func TestCheckUserPermissionNoAccess(t *testing.T) {
require.NoError(t, err)
defer db.Close()

pgDB := &auth.PostgresDB{Handle: db}
pgDB := &PostgresDB{Handle: db}

userEmail := "[email protected]"
bucket := "restricted-bucket"
Expand Down Expand Up @@ -112,7 +111,7 @@ func TestGetUserAccessiblePrefixes(t *testing.T) {
require.NoError(t, err)
defer db.Close()

pgDB := &auth.PostgresDB{Handle: db}
pgDB := &PostgresDB{Handle: db}

userEmail := "[email protected]"
bucket := "test-bucket"
Expand Down Expand Up @@ -148,7 +147,7 @@ func TestGetUserAccessiblePrefixesError(t *testing.T) {
require.NoError(t, err)
defer db.Close()

pgDB := &auth.PostgresDB{Handle: db}
pgDB := &PostgresDB{Handle: db}

userEmail := "[email protected]"
bucket := "test-bucket"
Expand Down Expand Up @@ -180,7 +179,7 @@ func TestGetUserAccessiblePrefixesNoAccess(t *testing.T) {
require.NoError(t, err)
defer db.Close()

pgDB := &auth.PostgresDB{Handle: db}
pgDB := &PostgresDB{Handle: db}

userEmail := "[email protected]"
bucket := "restricted-bucket"
Expand Down
Loading

0 comments on commit 36ff6fb

Please sign in to comment.