Skip to content

Commit dbe60ce

Browse files
committed
Add unit tests for Gotify adapter message sending functionality
- Implemented tests for sending messages with default and custom tokens. - Added tests for handling different priority levels and content types. - Included error handling test for axios request failures. - Updated the Gotify message interface to support an optional token parameter. - Modified the sendMessage method to utilize the custom token if provided.
1 parent a6ca6a5 commit dbe60ce

File tree

5 files changed

+4260
-10052
lines changed

5 files changed

+4260
-10052
lines changed

README.md

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,66 @@ Send push notifications from [ioBroker](https://iobroker.net/) to [Gotify](https
1717

1818
## Changelog
1919

20+
<!--
21+
Placeholder for the next version (at the beginning of the line):
22+
## **WORK IN PROGRESS**
23+
-->
24+
25+
## **WORK IN PROGRESS**
26+
27+
- (Thomas Pohl) Allow to overwrite token when sending messages (javascript only not for blockly)
28+
- (Thomas Pohl) Update dependencies
29+
2030
### 0.4.0
2131

22-
- (Thomas Pohl) Support for notification-manager was added
23-
- (Thomas Pohl) Blockly can now send messages with priority 10
32+
- (Thomas Pohl) Support for notification-manager was added
33+
- (Thomas Pohl) Blockly can now send messages with priority 10
2434

2535
### 0.3.0
2636

27-
- (Thomas Pohl) The token is stored now encrypted
28-
- (Thomas Pohl) node.js 22 is supported
37+
- (Thomas Pohl) The token is stored now encrypted
38+
- (Thomas Pohl) node.js 22 is supported
2939

3040
### 0.2.1
3141

32-
- (Thomas Pohl) Optimized startup behavior when adapter is not configured
42+
- (Thomas Pohl) Optimized startup behavior when adapter is not configured
3343

3444
### 0.2.0
3545

36-
- (Thomas Pohl) Add timeout for http calls
37-
- (Thomas Pohl) Update dependency versions
46+
- (Thomas Pohl) Add timeout for http calls
47+
- (Thomas Pohl) Update dependency versions
3848

3949
### 0.1.0
4050

41-
- (Thomas Pohl) Update to adapter-core 2.5.1
51+
- (Thomas Pohl) Update to adapter-core 2.5.1
4252

4353
### 0.0.2-RC1.0 (2022-02-09)
4454

45-
- (Thomas Pohl) Update dependencies
55+
- (Thomas Pohl) Update dependencies
4656

4757
### 0.0.1
4858

49-
- (Thomas Pohl) initial release
59+
- (Thomas Pohl) initial release
5060

5161
## Installation
5262

5363
### Preparation
5464

55-
- Login with you user in gotify
56-
- Create an application for ioBroker
57-
- Note the token of your new application
58-
![new application](img/newApplication.png)
65+
- Login with you user in gotify
66+
- Create an application for ioBroker
67+
- Note the token of your new application
68+
![new application](img/newApplication.png)
5969

6070
### In ioBroker
6171

62-
- Goto Adapter
63-
- Click on github-cat-icon
64-
- Go to Custom tab
65-
- Enter https://github.com/ThomasPohl/ioBroker.gotify
66-
- Install
67-
- Create a new instance for the gotify-adapter
68-
- Enter the Url auf you installation
69-
- Add the previously created token
72+
- Goto Adapter
73+
- Click on github-cat-icon
74+
- Go to Custom tab
75+
- Enter https://github.com/ThomasPohl/ioBroker.gotify
76+
- Install
77+
- Create a new instance for the gotify-adapter
78+
- Enter the Url auf you installation
79+
- Add the previously created token
7080

7181
## Usage
7282

@@ -79,10 +89,24 @@ If yoou choose Markdown as format you can use [Markdown](https://guides.github.c
7989

8090
### Javascript
8191

92+
Send a simple message using the default token:
93+
94+
```javascript
95+
sendTo('gotify.0', 'send', {
96+
title: 'DG lüften',
97+
message: 'Luftfeuchtigkeit im DG zu hoch!',
98+
});
99+
```
100+
101+
Send a message with a custom token (overrides the configured default token):
102+
82103
```javascript
83-
sendTo("gotify.0", "send", {
84-
title: "DG lüften",
85-
message: "Luftfeuchtigkeit im DG zu hoch!",
104+
sendTo('gotify.0', 'send', {
105+
title: 'Custom notification',
106+
message: 'This message uses a different token',
107+
priority: 8,
108+
contentType: 'text/markdown',
109+
token: 'AaBbCcDdEeFfGg123456',
86110
});
87111
```
88112

io-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
"type": "state",
147147
"common": {
148148
"name": {
149-
"en": "Connected to Gotify server",
149+
"en": "Connection to Gotify server",
150150
"de": "Verbindung mit Gotify Server",
151151
"ru": "Подключен к серверу Gotify",
152152
"pt": "Conectado ao servidor Gotify",

0 commit comments

Comments
 (0)