Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

FIX (tests): Skip Google Drive tests if env not provided

Rostislav Dugin6ef59e888b38
diff --git a/backend/internal/features/storages/model_test.go b/backend/internal/features/storages/model_test.go
index 40b4a32b..18833efb 100644
--- a/backend/internal/features/storages/model_test.go
+++ b/backend/internal/features/storages/model_test.go
@@ -74,15 +74,6 @@ func Test_Storage_BasicOperations(t *testing.T) {
S3Endpoint: "http://" + s3Container.endpoint,
},
},
- {
- name: "GoogleDriveStorage",
- storage: &google_drive_storage.GoogleDriveStorage{
- StorageID: uuid.New(),
- ClientID: config.GetEnv().TestGoogleDriveClientID,
- ClientSecret: config.GetEnv().TestGoogleDriveClientSecret,
- TokenJSON: config.GetEnv().TestGoogleDriveTokenJSON,
- },
- },
{
name: "NASStorage",
storage: &nas_storage.NASStorage{
@@ -99,6 +90,26 @@ func Test_Storage_BasicOperations(t *testing.T) {
},
}
+ // Add Google Drive storage test only if environment variables are available
+ env := config.GetEnv()
+ if env.TestGoogleDriveClientID != "" && env.TestGoogleDriveClientSecret != "" &&
+ env.TestGoogleDriveTokenJSON != "" {
+ testCases = append(testCases, struct {
+ name string
+ storage StorageFileSaver
+ }{
+ name: "GoogleDriveStorage",
+ storage: &google_drive_storage.GoogleDriveStorage{
+ StorageID: uuid.New(),
+ ClientID: env.TestGoogleDriveClientID,
+ ClientSecret: env.TestGoogleDriveClientSecret,
+ TokenJSON: env.TestGoogleDriveTokenJSON,
+ },
+ })
+ } else {
+ t.Log("Skipping Google Drive storage test: missing environment variables")
+ }
+
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Run("Test_TestConnection_ConnectionSucceeds", func(t *testing.T) {
@@ -221,9 +232,6 @@ func setupS3Container(ctx context.Context) (*S3Container, error) {
func validateEnvVariables(t *testing.T) {
env := config.GetEnv()
- assert.NotEmpty(t, env.TestGoogleDriveClientID, "TEST_GOOGLE_DRIVE_CLIENT_ID is empty")
- assert.NotEmpty(t, env.TestGoogleDriveClientSecret, "TEST_GOOGLE_DRIVE_CLIENT_SECRET is empty")
- assert.NotEmpty(t, env.TestGoogleDriveTokenJSON, "TEST_GOOGLE_DRIVE_TOKEN_JSON is empty")
assert.NotEmpty(t, env.TestMinioPort, "TEST_MINIO_PORT is empty")
assert.NotEmpty(t, env.TestNASPort, "TEST_NAS_PORT is empty")
}