Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Ntfy_archive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Ntfy_archive
Commits
fd71589f
Commit
fd71589f
authored
3 years ago
by
Philipp Heckel
Browse files
Options
Downloads
Patches
Plain Diff
More test; begin test infra stuff
parent
37fafd09
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.github/workflows/test.yaml
+11
-5
11 additions, 5 deletions
.github/workflows/test.yaml
Makefile
+4
-3
4 additions, 3 deletions
Makefile
config/config_test.go
+12
-0
12 additions, 0 deletions
config/config_test.go
server/server_test.go
+36
-0
36 additions, 0 deletions
server/server_test.go
with
63 additions
and
8 deletions
.github/workflows/test.yaml
+
11
−
5
View file @
fd71589f
...
...
@@ -7,12 +7,18 @@ jobs:
-
name
:
Install Go
uses
:
actions/setup-go@v2
with
:
go-version
:
'
1.1
6
.x'
go-version
:
'
1.1
7
.x'
-
name
:
Checkout code
uses
:
actions/checkout@v2
-
name
:
Install test dependencies
run
:
sudo apt-get install netcat-openbsd
-
name
:
Install dependencies
run
:
sudo apt update && sudo apt install -y python3-pip
-
name
:
Install mkdocs
run
:
sudo pip3 install mkdocs mkdocs-material mkdocs-minify-plugin
-
name
:
Build docs
run
:
make docs
-
name
:
Run tests, formatting, vetting and linting
run
:
make check
-
name
:
Run and upload coverage to codecov.io
run
:
make coverage coverage-upload
\ No newline at end of file
-
name
:
Run coverage
run
:
make coverage
# - name: Upload coverage to codecov.io
# run: make coverage-upload
This diff is collapsed.
Click to expand it.
Makefile
+
4
−
3
View file @
fd71589f
...
...
@@ -38,6 +38,10 @@ help:
@
echo
" make install-lint - Install golint"
# Documentation
docs
:
.PHONY
mkdocs build
# Test/check targets
check
:
test fmt-check vet lint staticcheck
...
...
@@ -88,9 +92,6 @@ staticcheck: .PHONY
# Building targets
docs
:
.PHONY
mkdocs build
build-deps
:
docs
which arm-linux-gnueabi-gcc
||
{
echo
"ERROR: ARMv6/v7 cross compiler not installed. On Ubuntu, run: apt install gcc-arm-linux-gnueabi"
;
exit
1
;
}
which aarch64-linux-gnu-gcc
||
{
echo
"ERROR: ARM64 cross compiler not installed. On Ubuntu, run: apt install gcc-aarch64-linux-gnu"
;
exit
1
;
}
...
...
This diff is collapsed.
Click to expand it.
config/config_test.go
0 → 100644
+
12
−
0
View file @
fd71589f
package
config_test
import
(
"github.com/stretchr/testify/assert"
"heckel.io/ntfy/config"
"testing"
)
func
TestConfig_New
(
t
*
testing
.
T
)
{
c
:=
config
.
New
(
":1234"
)
assert
.
Equal
(
t
,
":1234"
,
c
.
ListenHTTP
)
}
This diff is collapsed.
Click to expand it.
server/server_test.go
0 → 100644
+
36
−
0
View file @
fd71589f
package
server
import
(
"encoding/json"
"github.com/stretchr/testify/assert"
"heckel.io/ntfy/config"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func
TestServer_Publish
(
t
*
testing
.
T
)
{
s
:=
newTestServer
(
t
,
newTestConfig
())
rr
:=
httptest
.
NewRecorder
()
req
,
_
:=
http
.
NewRequest
(
"PUT"
,
"/mytopic"
,
strings
.
NewReader
(
"my message"
))
s
.
handle
(
rr
,
req
)
var
m
message
assert
.
Nil
(
t
,
json
.
NewDecoder
(
rr
.
Body
)
.
Decode
(
&
m
))
assert
.
NotEmpty
(
t
,
m
.
ID
)
assert
.
Equal
(
t
,
"my message"
,
m
.
Message
)
}
func
newTestConfig
()
*
config
.
Config
{
return
config
.
New
(
":80"
)
}
func
newTestServer
(
t
*
testing
.
T
,
config
*
config
.
Config
)
*
Server
{
server
,
err
:=
New
(
config
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
server
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment