Skip to content

Commit 2da7bc6

Browse files
committed
Add some tests to ensure generated payloads are expected
Also push package to github (this might not work...) Signed-off-by: Adam Warner <me@adamwarner.co.uk>
1 parent cd95f17 commit 2da7bc6

14 files changed

+540
-4
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,18 @@ jobs:
3535
-
3636
name: Build
3737
run: dotnet build $SOLUTION --configuration $BUILD_CONFIG --no-restore
38+
-
39+
name: Run Tests
40+
run: dotnet test --no-restore --verbosity normal
3841
-
3942
name: Publish
4043
if: github.event_name != 'pull_request'
41-
run: nuget push Matterhook.NET.MatterhookClient/bin/Release/*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}}
44+
run: |
45+
if [ "${{ secrets.NUGET_API_KEY }}" != "" ]; then
46+
echo "Pushing to nuget.org"
47+
nuget push Matterhook.NET.MatterhookClient/bin/Release/*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}}
48+
else
49+
echo "Not pushing to nuget.org, no NUGET_API_KEY set in repo secrets"
50+
fi
51+
echo "Pushing to github packages"
52+
nuget push Matterhook.NET.MatterhookClient/bin/Release/*.nupkg -Source 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' -ApiKey ${{secrets.GITHUB_TOKEN}}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"channel": "testChannel",
3+
"username": "Awesome-O-Matic",
4+
"icon_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Robot_icon.svg/2000px-Robot_icon.svg.png",
5+
"text": "Hello, I was posted using [Matterhook.NET.MatterhookClient](https://github.com/promofaux/Matterhook.NET.MatterhookClient)",
6+
"attachments": [
7+
{
8+
"fields": [
9+
{
10+
"title": "Long Field.",
11+
"value": "Testing with a very long piece of text that will take up the whole width of the table. And then some more text to make it extra long.",
12+
"short": false
13+
},
14+
{
15+
"title": "Column One",
16+
"value": "Testing",
17+
"short": true
18+
},
19+
{
20+
"title": "Column Two",
21+
"value": "Testing",
22+
"short": true
23+
},
24+
{
25+
"title": "Another Field",
26+
"value": "Testing",
27+
"short": false
28+
}
29+
],
30+
"fallback": "test",
31+
"color": "#FF8000",
32+
"pretext": "This is optional pretext that shows above the attachment.",
33+
"text": "This is the text of the attachment. It should appear just above an image of the Mattermost logo. The left border of the attachment should be colored orange, and below the image it should include additional fields that are formatted in columns. At the top of the attachment, there should be an author name followed by a bolded title. Both the author name and the title should be hyperlinks.",
34+
"author_name": "Mattermost",
35+
"author_link": "http://www.mattermost.org/",
36+
"author_icon": "http://www.mattermost.org/wp-content/uploads/2016/04/icon_WS.png",
37+
"title": "Example Attachment",
38+
"title_link": "http://docs.mattermost.com/developer/message-attachments.html",
39+
"image_url": "http://www.mattermost.org/wp-content/uploads/2016/03/logoHorizontal_WS.png"
40+
}
41+
]
42+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"channel": "testChannel",
3+
"username": "Awesome-O-Matic",
4+
"text": "Hello, I was posted using [Matterhook.NET.MatterhookClient](https://github.com/promofaux/Matterhook.NET.MatterhookClient)"
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"channel": "testChannel",
3+
"username": "Awesome-O-Matic",
4+
"text": "Hello, I was posted using [Matterhook.NET.MatterhookClient](https://github.com/promofaux/Matterhook.NET.MatterhookClient)",
5+
"props": {
6+
"card": "**THIS IS A CARD**\n\nIt came from [Matterhook.NET.MatterhookClient](https://github.com/promofaux/Matterhook.NET.MatterhookClient)"
7+
}
8+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"channel": "testChannel",
3+
"username": "Awesome-O-Matic",
4+
"icon_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Robot_icon.svg/2000px-Robot_icon.svg.png",
5+
"text": "Message Text Example",
6+
"attachments": [
7+
{
8+
"text": "Attachment Text Example",
9+
"actions": [
10+
{
11+
"name": "Merge",
12+
"integration": {
13+
"url": "https://notarealoutgoingwebhook.justfortests",
14+
"context": {
15+
"pr": 1234,
16+
"action": "merge"
17+
}
18+
}
19+
},
20+
{
21+
"name": "Notify",
22+
"integration": {
23+
"url": "https://notarealoutgoingwebhook.justfortests",
24+
"context": {
25+
"text": "code was pushed."
26+
}
27+
}
28+
}
29+
]
30+
}
31+
]
32+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"channel": "testChannel",
3+
"username": "Awesome-O-Matic",
4+
"icon_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Robot_icon.svg/2000px-Robot_icon.svg.png",
5+
"text": "This is a message menu with channels source posted using [Matterhook.NET.MatterhookClient](https://github.com/promofaux/Matterhook.NET.MatterhookClient)",
6+
"attachments": [
7+
{
8+
"pretext": "This is optional pretext that shows above the attachment.",
9+
"text": "This is the text of the attachment. ",
10+
"actions": [
11+
{
12+
"name": "channels",
13+
"integration": {
14+
"url": "https://notarealoutgoingwebhook.justfortests",
15+
"context": {
16+
"active": "false"
17+
}
18+
},
19+
"type": "select",
20+
"data_source": "channels"
21+
}
22+
]
23+
}
24+
]
25+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"channel": "testChannel",
3+
"username": "Awesome-O-Matic",
4+
"icon_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Robot_icon.svg/2000px-Robot_icon.svg.png",
5+
"text": "This is a menu message posted using [Matterhook.NET.MatterhookClient](https://github.com/promofaux/Matterhook.NET.MatterhookClient)",
6+
"attachments": [
7+
{
8+
"pretext": "This is optional pretext that shows above the attachment.",
9+
"text": "This is the text of the attachment. ",
10+
"actions": [
11+
{
12+
"name": "Test",
13+
"integration": {
14+
"url": "https://notarealoutgoingwebhook.justfortests",
15+
"context": {
16+
"text": "Some data to send always."
17+
}
18+
},
19+
"type": "select",
20+
"options": [
21+
{
22+
"text": "Option1",
23+
"value": "value1"
24+
},
25+
{
26+
"text": "Option2",
27+
"value": "value2"
28+
},
29+
{
30+
"text": "Option3",
31+
"value": "value3"
32+
}
33+
]
34+
}
35+
]
36+
}
37+
]
38+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"channel": "testChannel",
3+
"username": "Awesome-O-Matic",
4+
"icon_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Robot_icon.svg/2000px-Robot_icon.svg.png",
5+
"text": "This is a message menu with users source posted using [Matterhook.NET.MatterhookClient](https://github.com/promofaux/Matterhook.NET.MatterhookClient)",
6+
"attachments": [
7+
{
8+
"pretext": "This is optional pretext that shows above the attachment.",
9+
"text": "This is the text of the attachment. ",
10+
"actions": [
11+
{
12+
"name": "Users",
13+
"integration": {
14+
"url": "https://notarealoutgoingwebhook.justfortests",
15+
"context": {
16+
"mood": "sad"
17+
}
18+
},
19+
"type": "select",
20+
"data_source": "users"
21+
}
22+
]
23+
}
24+
]
25+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
11+
<PackageReference Include="xunit" Version="2.4.1" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
<PrivateAssets>all</PrivateAssets>
15+
</PackageReference>
16+
<PackageReference Include="coverlet.collector" Version="1.3.0">
17+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18+
<PrivateAssets>all</PrivateAssets>
19+
</PackageReference>
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<ProjectReference Include="..\Matterhook.NET.MatterhookClient\Matterhook.NET.MatterhookClient.csproj" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<None Update="ExpectedJson\UsersMenuMessage.json">
28+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
29+
</None>
30+
<None Update="ExpectedJson\ChannelsMenuMessage.json">
31+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
32+
</None>
33+
<None Update="ExpectedJson\MenuMessage.json">
34+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
35+
</None>
36+
<None Update="ExpectedJson\ButtonsMessage.json">
37+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
38+
</None>
39+
<None Update="ExpectedJson\AdvancedMessage.json">
40+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
41+
</None>
42+
<None Update="ExpectedJson\BasicMessageWithCard.json">
43+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
44+
</None>
45+
<None Update="ExpectedJson\BasicMessage.json">
46+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
47+
</None>
48+
</ItemGroup>
49+
50+
</Project>

0 commit comments

Comments
 (0)