Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorScenarios = map[string]map[string]interface{}{
"invalid_credentials": {
"status_code": 401,
"error": "Invalid credentials",
"message": "The provided credentials are invalid",
},
"bucket_not_found": {
"status_code": 404,
"error": "Bucket not found",
"message": "The specified bucket does not exist",
},
"access_denied": {
"status_code": 403,
"error": "Access denied",
"message": "You do not have permission to perform this action",
},
"rate_limited": {
"status_code": 429,
"error": "Rate limit exceeded",
"message": "Too many requests, please try again later",
},
"server_error": {
"status_code": 500,
"error": "Internal server error",
"message": "An unexpected error occurred",
},
}
Error scenarios for testing
View Source
var SampleAPIResponses = map[string]interface{}{ "accounts": []map[string]interface{}{ { "id": "1234567890abcdef1234567890abcdef", "name": "Test Account", "status": "active", }, { "id": "fedcba0987654321fedcba0987654321", "name": "Another Account", "status": "active", }, }, "buckets": []map[string]interface{}{ { "name": "test-bucket", "creation_date": "2024-01-01T00:00:00Z", "location": map[string]interface{}{ "type": "region", "name": "auto", }, }, { "name": "another-bucket", "creation_date": "2024-01-02T00:00:00Z", "location": map[string]interface{}{ "type": "region", "name": "auto", }, }, }, "objects": []map[string]interface{}{ { "key": "test-file.txt", "size": 1024, "last_modified": "2024-01-01T12:00:00Z", "etag": "d41d8cd98f00b204e9800998ecf8427e", }, { "key": "folder/nested-file.txt", "size": 2048, "last_modified": "2024-01-01T13:00:00Z", "etag": "098f6bcd4621d373cade4e832627b4f6", }, }, }
Sample API responses
View Source
var SampleConfig = map[string]interface{}{ "version": "1.0.0", "current_profile": "default", "profiles": map[string]interface{}{ "default": map[string]interface{}{ "name": "Default Profile", "account_id": "1234567890abcdef1234567890abcdef", "access_key": "AKIAIOSFODNN7EXAMPLE", "secret_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "bucket": "my-test-bucket", "endpoint": "https://abc123.r2.cloudflarestorage.com", "region": "auto", "created_at": time.Now().Format(time.RFC3339), }, "secondary": map[string]interface{}{ "name": "Secondary Profile", "account_id": "fedcba0987654321fedcba0987654321", "access_key": "AKIAI44QH8DHBEXAMPLE", "secret_key": "je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY", "bucket": "my-other-bucket", "endpoint": "https://def456.r2.cloudflarestorage.com", "region": "auto", "created_at": time.Now().Add(-24 * time.Hour).Format(time.RFC3339), }, }, "settings": map[string]interface{}{ "theme": "default", "tutorial_completed": false, "accessibility": map[string]interface{}{ "screen_reader": false, "high_contrast": false, "large_text": false, }, }, }
Sample configuration data for testing
View Source
var SampleThemes = map[string]interface{}{ "default": map[string]interface{}{ "name": "Default", "description": "Default R2Go2 theme", "colors": map[string]interface{}{ "primary": "#007bff", "secondary": "#6c757d", "success": "#28a745", "danger": "#dc3545", "warning": "#ffc107", "info": "#17a2b8", "light": "#f8f9fa", "dark": "#343a40", }, "background": map[string]interface{}{ "main": "#ffffff", "secondary": "#f8f9fa", "accent": "#e9ecef", }, "text": map[string]interface{}{ "primary": "#212529", "secondary": "#6c757d", "muted": "#6c757d", }, }, "dark": map[string]interface{}{ "name": "Dark", "description": "Dark theme for low-light environments", "colors": map[string]interface{}{ "primary": "#0d6efd", "secondary": "#6c757d", "success": "#198754", "danger": "#dc3545", "warning": "#ffc107", "info": "#0dcaf0", "light": "#f8f9fa", "dark": "#212529", }, "background": map[string]interface{}{ "main": "#212529", "secondary": "#343a40", "accent": "#495057", }, "text": map[string]interface{}{ "primary": "#ffffff", "secondary": "#adb5bd", "muted": "#6c757d", }, }, }
Sample themes for testing
View Source
var TestBucketNames = []string{
"test-bucket",
"test-bucket-123",
"my-test-bucket",
"r2go2-test",
"bucket-with-dashes",
"bucket_with_underscores",
"bucket123",
"a",
"bucket-name-that-is-exactly-sixty-three-characters-long-123",
}
Common bucket names for testing
View Source
var TestFileNames = []string{
"small-file.txt",
"medium-file.txt",
"large-file.txt",
"file-with-spaces.txt",
"file-with-特殊字符.txt",
"very-long-filename-that-tests-path-handling-capabilities.txt",
"file.ext",
"file.tar.gz",
"file.with.many.dots.txt",
"UPPERCASE.TXT",
"lowercase.txt",
"MixedCase.Txt",
}
Common test file names
View Source
var TestFileSizes = []int{
1024,
10240,
102400,
1048576,
10485760,
104857600,
}
Common test file sizes for performance testing
Functions ¶
func GenerateTestDirectoryName ¶
func GenerateTestDirectoryName() string
GenerateTestDirectoryName creates a unique test directory name
func GenerateTestFile ¶
GenerateTestFile creates test file content of specified size
func GenerateTestFiles ¶
GenerateTestFiles creates multiple test files with different sizes
func GetSampleAPIResponse ¶
func GetSampleAPIResponse(responseType string) interface{}
GetSampleAPIResponse returns a sample API response by type
func GetSampleConfig ¶
func GetSampleConfig() map[string]interface{}
GetSampleConfig returns a copy of the sample configuration
func GetSampleThemes ¶
func GetSampleThemes() map[string]interface{}
GetSampleThemes returns a copy of the sample themes
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.