Debian Codegraph @

testing/integration/ntfy/README.md

raw
1 # Ntfy Integration Tests
2
3 This directory contains integration tests for the Ntfy push notification service in Shoutrrr.
4 The tests validate ntfy functionality by mocking HTTP requests to the ntfy API, ensuring feature parity with the ntfy.sh service.
5
6 ## Test Coverage
7
8 ### Configuration Options
9
10 - URL parsing for `ntfy://` scheme
11 - Topic path handling (simple and nested paths)
12 - Username/password authentication from URL
13 - Query parameters (priority, tags, markdown, cache, firebase, title, click, attach, actions, delay, email, icon, filename)
14 - Default values (https scheme, ntfy.sh host, default priority)
15 - DisableTLS option (forces HTTP scheme)
16 - DisableTLSVerification option
17
18 ### Message Sending
19
20 - Basic message sending
21 - Empty message handling
22 - Title via URL query parameter
23 - Title via params map
24 - Priority configuration
25 - Tags configuration
26 - Markdown formatting
27 - Click action links
28 - Attachment URLs
29 - Action buttons
30 - Delayed delivery
31 - Email notifications
32 - Icon URLs
33 - Filename for attachments
34 - Unicode message support
35 - Basic authentication
36
37 ### Error Handling
38
39 - HTTP error responses (400, 401, 403, 404, 500)
40 - Network errors (connection refused, timeout)
41 - Malformed API error responses
42 - Empty error body handling
43
44 ## Running the Tests
45
46 ### Mocked Integration Tests (Default)
47
48 Run all integration tests with mocked ntfy API responses:
49
50 ```bash
51 go test ./testing/integration/ntfy/ -v
52 ```
53
54 Or run specific test categories:
55
56 ```bash
57 # Run specific test categories
58 go test ./testing/integration/ntfy/ -run TestServiceInitialization -v
59 go test ./testing/integration/ntfy/ -run TestSend -v
60 go test ./testing/integration/ntfy/ -run 'TestSendWith.*Error|TestSendWith(400|401|403|404|500)|TestSendWithTimeout|TestSendWith(Nil|Empty)Params' -v
61 ```
62
63 ## Test Structure
64
65 The test suite is organized as a flat directory structure with individual test files for each feature category:
66
67 ```bash
68 testing/integration/ntfy/
69 ├── utils_test.go # Helper functions and mock implementations
70 ├── config_test.go # Configuration and URL parsing tests
71 ├── send_test.go # Message sending tests
72 ├── errors_test.go # Error handling tests
73 ├── api_compliance_test.go # API compliance tests
74 └── README.md # This documentation
75 ```
76
77 ### Test Organization
78
79 Each test file contains independent black-box tests for specific ntfy service behaviors.
80 Tests validate that the service correctly interacts with external APIs without inspecting internal data structures:
81
82 - **Config Tests** (`config_test.go`): Service configuration application in external API requests
83 - **Send Tests** (`send_test.go`): Service handling of various message types and external API responses
84 - **Error Tests** (`errors_test.go`): Service error handling when external APIs return failures
85 - **API Compliance Tests** (`api_compliance_test.go`): URL format, HTTP method, Content-Type including Markdown, User-Agent, and Basic Auth behavior