Skip to content

Commit 1f362df

Browse files
committed
feeds-v3 collections update
1 parent 367bc5e commit 1f362df

14 files changed

+535
-44
lines changed

FEEDS_INTEGRATION_TESTS.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Feeds Integration Tests
2+
3+
This document describes the comprehensive integration tests for the GetStream Go SDK Feeds API.
4+
5+
## Overview
6+
7+
The integration tests in `feeds_integration_test.go` provide comprehensive coverage of all Feeds API functionality, following the same patterns as the PHP SDK integration tests. These tests demonstrate real-world usage patterns and serve as both validation and documentation.
8+
9+
## Test Structure
10+
11+
The tests are organized in a logical flow with **36 comprehensive test scenarios**:
12+
13+
1. **Environment Setup** - User and feed creation
14+
2. **Activity Operations** - Create, read, update, delete activities
15+
3. **Reaction Operations** - Add, query, delete reactions
16+
4. **Comment Operations** - Add, read, update, delete comments
17+
5. **Bookmark Operations** - Add, query, update, delete bookmarks
18+
6. **Follow Operations** - Follow, query, unfollow users
19+
7. **Batch Operations** - Bulk activity operations
20+
8. **Advanced Operations** - Polls, pins, moderation
21+
9. **Error Handling** - Testing various error scenarios
22+
10. **Real-world Usage** - Comprehensive usage demonstration
23+
11. **Feed Group CRUD** - Complete feed group lifecycle management
24+
12. **Feed View CRUD** - Custom feed view creation and management
25+
13. **Feed Management** - Individual feed operations and querying
26+
14. **Batch Operations** - Bulk feed creation and management
27+
28+
## Running the Tests
29+
30+
### Prerequisites
31+
32+
1. Set up environment variables for Stream credentials:
33+
```bash
34+
export STREAM_KEY="your-stream-api-key"
35+
export STREAM_SECRET="your-stream-api-secret"
36+
```
37+
38+
2. Or create a `.env` file in the project root:
39+
```
40+
STREAM_KEY=your-stream-api-key
41+
STREAM_SECRET=your-stream-api-secret
42+
```
43+
44+
### Running All Integration Tests
45+
46+
```bash
47+
# Run all integration tests
48+
go test -v -run TestFeedIntegrationSuite
49+
50+
# Run with race detection
51+
go test -v -race -run TestFeedIntegrationSuite
52+
53+
# Skip integration tests in short mode
54+
go test -short ./...
55+
```
56+
57+
### Running Individual Test Categories
58+
59+
```bash
60+
# Run specific test categories
61+
go test -v -run TestFeedIntegrationSuite/Test02_CreateActivity
62+
go test -v -run TestFeedIntegrationSuite/Test08_AddComment
63+
go test -v -run TestFeedIntegrationSuite/Test32_RealWorldUsageDemo
64+
```
65+
66+
## Code Snippets
67+
68+
The tests include comprehensive code snippets marked with `// snippet-start:` and `// snippet-end:` comments. These snippets demonstrate:
69+
70+
### Basic Activity Operations
71+
- `AddActivity` - Creating activities with various content types
72+
- `QueryActivities` - Querying activities with filters
73+
- `GetActivity` - Retrieving single activities
74+
- `UpdateActivity` - Updating activity content
75+
- `DeleteActivity` - Soft and hard deletion
76+
77+
### Advanced Features
78+
- `AddActivityWithImageAttachment` - Activities with media
79+
- `AddVideoActivity` - Video content activities
80+
- `AddStoryActivityWithExpiration` - Temporary content
81+
- `AddActivityToMultipleFeeds` - Cross-posting
82+
83+
### Reactions and Comments
84+
- `AddReaction` - Adding reactions to activities
85+
- `QueryActivityReactions` - Querying reactions
86+
- `AddComment` - Adding comments to activities
87+
- `QueryComments` - Querying comments with filters
88+
89+
### Social Features
90+
- `Follow` / `Unfollow` - User following
91+
- `AddBookmark` - Bookmarking content
92+
- `CreatePoll` / `VotePoll` - Poll functionality
93+
94+
### Feed Group & View Management
95+
- `ListFeedGroups` / `CreateFeedGroup` - Feed group management
96+
- `GetFeedGroup` / `UpdateFeedGroup` / `DeleteFeedGroup` - Feed group CRUD
97+
- `ListFeedViews` / `CreateFeedView` - Feed view management
98+
- `GetFeedView` / `UpdateFeedView` / `DeleteFeedView` - Feed view CRUD
99+
- `CreateFeedsBatch` - Bulk feed creation
100+
- `QueryFeeds` - Feed querying with filters
101+
102+
### Error Handling
103+
- `HandleInvalidActivityId` - Invalid ID handling
104+
- `HandleEmptyActivityText` - Validation errors
105+
- `HandleInvalidUserId` - Authentication errors
106+
107+
## Test Features
108+
109+
### Automatic Cleanup
110+
- All created resources are automatically cleaned up after tests
111+
- Uses hard deletion to ensure clean test environment
112+
- Tracks created activities, comments, and other resources
113+
114+
### Error Handling
115+
- Tests both success and failure scenarios
116+
- Demonstrates proper error handling patterns
117+
- Includes authentication and authorization testing
118+
119+
### Real-world Patterns
120+
- Comprehensive usage demonstration
121+
- Multi-step workflows (post → react → comment → bookmark)
122+
- Pagination and filtering examples
123+
124+
### Documentation
125+
- Each test includes descriptive output
126+
- Code snippets are clearly marked for documentation extraction
127+
- Follows the same patterns as other SDK integration tests
128+
129+
## Test Data
130+
131+
The tests use:
132+
- Unique user IDs generated with UUIDs
133+
- Temporary test data that doesn't affect production
134+
- Automatic cleanup to prevent data accumulation
135+
- Realistic test scenarios (coffee shop posts, polls, etc.)
136+
137+
## Notes
138+
139+
- Tests are designed to run against a real Stream API instance
140+
- Some features may be skipped if not available in your Stream plan
141+
- Tests include comprehensive logging for debugging
142+
- All tests are independent and can run in any order
143+
- Resource cleanup ensures tests don't interfere with each other
144+
145+
## Troubleshooting
146+
147+
### Common Issues
148+
149+
1. **Authentication Errors**: Ensure STREAM_KEY and STREAM_SECRET are set correctly
150+
2. **Feature Not Available**: Some tests may be skipped if features aren't enabled in your Stream plan
151+
3. **Rate Limiting**: Tests include appropriate delays and error handling for rate limits
152+
4. **Network Issues**: Tests include retry logic and proper error handling
153+
154+
### Debug Mode
155+
156+
Run tests with verbose output to see detailed execution:
157+
158+
```bash
159+
go test -v -run TestFeedIntegrationSuite 2>&1 | tee test_output.log
160+
```
161+
162+
This will show all test output including the emoji-decorated progress indicators and detailed operation logs.

call.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chat.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chat_test.go

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common_test.go

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

feeds-v3.go

Lines changed: 39 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

feeds_integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,8 +1289,8 @@ func test26ModerateActivity(t *testing.T, ctx context.Context, feedsClient *gets
12891289

12901290
// snippet-start: ModerateActivity
12911291
moderationResponse, err := feedsClient.ActivityFeedback(ctx, activityID, &getstream.ActivityFeedbackRequest{
1292-
//Report: getstream.PtrTo(true),
1293-
//Reason: getstream.PtrTo("inappropriate_content"),
1292+
// Report: getstream.PtrTo(true),
1293+
// Reason: getstream.PtrTo("inappropriate_content"),
12941294
UserID: &testUserID2, // Different user reporting
12951295
})
12961296
// snippet-end: ModerateActivity

feeds_test.go

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

img.png

24.4 KB
Loading

0 commit comments

Comments
 (0)