Download test-github-storage.php from CatPtain/VvvebJs: direct link, hf CLI and curl.
- Browser
- Download file 1.86 kB
-
https://huggingface.co/spaces/CatPtain/VvvebJs/resolve/main/test-github-storage.php
- Command line
-
hf download hf://spaces/CatPtain/VvvebJs/test-github-storage.php
-
curl -L -o test-github-storage.php https://huggingface.co/spaces/CatPtain/VvvebJs/resolve/main/test-github-storage.php
1.86 kB
| // Test script to verify GitHub directory creation and file saving | |
| require_once 'storage.php'; | |
| echo "Testing GitHub Storage Directory Creation and File Saving...\n"; | |
| // Initialize GitHub storage | |
| $storage = new GitHubStorage(); | |
| // Test 1: Verify configuration | |
| echo "1. Checking GitHub configuration...\n"; | |
| if (!$storage->isConfigured()) { | |
| echo "ERROR: GitHub storage is not properly configured.\n"; | |
| echo "Please check your GitHub token and repository settings.\n"; | |
| exit(1); | |
| } | |
| echo "✓ GitHub configuration is valid.\n"; | |
| // Test 2: Test directory creation | |
| echo "2. Testing directory creation...\n"; | |
| $userPath = $storage->getUserPath(); | |
| if (!$userPath) { | |
| echo "ERROR: Could not determine user path.\n"; | |
| exit(1); | |
| } | |
| echo "User path: $userPath\n"; | |
| // Test 3: Test file saving | |
| echo "3. Testing file save...\n"; | |
| $testContent = "<!DOCTYPE html>\n<html>\n<head>\n<title>Test Page</title>\n</head>\n<body>\n<h1>Test Content</h1>\n<p>This is a test file created at " . date('Y-m-d H:i:s') . "</p>\n</body>\n</html>"; | |
| $testFilename = "test-" . date('YmdHis') . ".html"; | |
| $result = $storage->save($testFilename, $testContent); | |
| if ($result) { | |
| echo "✓ File saved successfully: $testFilename\n"; | |
| // Test 4: Verify file can be loaded | |
| echo "4. Testing file load...\n"; | |
| $loadedContent = $storage->load($testFilename); | |
| if ($loadedContent === $testContent) { | |
| echo "✓ File loaded successfully and content matches.\n"; | |
| } else { | |
| echo "WARNING: File loaded but content doesn't match exactly.\n"; | |
| echo "Expected length: " . strlen($testContent) . "\n"; | |
| echo "Actual length: " . strlen($loadedContent) . "\n"; | |
| } | |
| } else { | |
| echo "ERROR: Failed to save test file.\n"; | |
| exit(1); | |
| } | |
| echo "\nAll tests completed successfully!\n"; | |