Skip to content

Commit 6ef59e8

Browse files
FIX (tests): Skip Google Drive tests if env not provided
1 parent 2009eab commit 6ef59e8

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

backend/internal/features/storages/model_test.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ func Test_Storage_BasicOperations(t *testing.T) {
7474
S3Endpoint: "http://" + s3Container.endpoint,
7575
},
7676
},
77-
{
78-
name: "GoogleDriveStorage",
79-
storage: &google_drive_storage.GoogleDriveStorage{
80-
StorageID: uuid.New(),
81-
ClientID: config.GetEnv().TestGoogleDriveClientID,
82-
ClientSecret: config.GetEnv().TestGoogleDriveClientSecret,
83-
TokenJSON: config.GetEnv().TestGoogleDriveTokenJSON,
84-
},
85-
},
8677
{
8778
name: "NASStorage",
8879
storage: &nas_storage.NASStorage{
@@ -99,6 +90,26 @@ func Test_Storage_BasicOperations(t *testing.T) {
9990
},
10091
}
10192

93+
// Add Google Drive storage test only if environment variables are available
94+
env := config.GetEnv()
95+
if env.TestGoogleDriveClientID != "" && env.TestGoogleDriveClientSecret != "" &&
96+
env.TestGoogleDriveTokenJSON != "" {
97+
testCases = append(testCases, struct {
98+
name string
99+
storage StorageFileSaver
100+
}{
101+
name: "GoogleDriveStorage",
102+
storage: &google_drive_storage.GoogleDriveStorage{
103+
StorageID: uuid.New(),
104+
ClientID: env.TestGoogleDriveClientID,
105+
ClientSecret: env.TestGoogleDriveClientSecret,
106+
TokenJSON: env.TestGoogleDriveTokenJSON,
107+
},
108+
})
109+
} else {
110+
t.Log("Skipping Google Drive storage test: missing environment variables")
111+
}
112+
102113
for _, tc := range testCases {
103114
t.Run(tc.name, func(t *testing.T) {
104115
t.Run("Test_TestConnection_ConnectionSucceeds", func(t *testing.T) {
@@ -221,9 +232,6 @@ func setupS3Container(ctx context.Context) (*S3Container, error) {
221232

222233
func validateEnvVariables(t *testing.T) {
223234
env := config.GetEnv()
224-
assert.NotEmpty(t, env.TestGoogleDriveClientID, "TEST_GOOGLE_DRIVE_CLIENT_ID is empty")
225-
assert.NotEmpty(t, env.TestGoogleDriveClientSecret, "TEST_GOOGLE_DRIVE_CLIENT_SECRET is empty")
226-
assert.NotEmpty(t, env.TestGoogleDriveTokenJSON, "TEST_GOOGLE_DRIVE_TOKEN_JSON is empty")
227235
assert.NotEmpty(t, env.TestMinioPort, "TEST_MINIO_PORT is empty")
228236
assert.NotEmpty(t, env.TestNASPort, "TEST_NAS_PORT is empty")
229237
}

0 commit comments

Comments
 (0)