Skip to content

Commit ed0856b

Browse files
committed
Add tests
1 parent 7c527c8 commit ed0856b

11 files changed

Lines changed: 833 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
name: Run Tests
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: '1.25'
20+
cache: true
21+
22+
- name: Download dependencies
23+
run: go mod download
24+
25+
- name: Verify dependencies
26+
run: go mod verify
27+
28+
- name: Run tests
29+
run: go test -v -race -timeout 5m -coverprofile=coverage.out -covermode=atomic
30+
31+
- name: Display coverage
32+
run: go tool cover -func=coverage.out
33+
34+
- name: Upload coverage to Codecov
35+
uses: codecov/codecov-action@v4
36+
with:
37+
files: ./coverage.out
38+
flags: unittests
39+
fail_ci_if_error: false
40+
env:
41+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
42+
43+
lint:
44+
name: Run Linters
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
51+
- name: Set up Go
52+
uses: actions/setup-go@v5
53+
with:
54+
go-version: '1.25'
55+
cache: true
56+
57+
- name: Run go vet
58+
run: go vet ./...
59+
60+
- name: Run gofmt
61+
run: |
62+
if [ -n "$(gofmt -l .)" ]; then
63+
echo "Go code is not formatted:"
64+
gofmt -d .
65+
exit 1
66+
fi
67+
68+
- name: Run staticcheck
69+
uses: dominikh/staticcheck-action@v1
70+
with:
71+
version: "latest"
72+
install-go: false

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# RTask
22

3+
[![Tests](https://github.com/sam701/rtask/actions/workflows/test.yml/badge.svg)](https://github.com/sam701/rtask/actions/workflows/test.yml)
4+
35
RTask is a secure task runner with API key management that exposes system commands as HTTP endpoints. It provides authenticated access to configured tasks with rate limiting, metrics collection, and secure API key management.
46

57
## Features
@@ -15,7 +17,7 @@ RTask is a secure task runner with API key management that exposes system comman
1517

1618
### Prerequisites
1719

18-
- Go 1.24.3 or later
20+
- Go 1.25 or later
1921
- Optional: [just](https://github.com/casey/just) for build automation
2022

2123
### Build from Source
@@ -215,6 +217,26 @@ Available metrics:
215217

216218
## Development
217219

220+
### Running Tests
221+
222+
Run all tests:
223+
224+
```bash
225+
go test -v
226+
```
227+
228+
Run specific test:
229+
230+
```bash
231+
go test -v -run TestSyncTask_Success
232+
```
233+
234+
Run tests with timeout:
235+
236+
```bash
237+
go test -v -timeout 3m
238+
```
239+
218240
### Running in Debug Mode
219241

220242
```bash

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module rtask
22

3-
go 1.24.3
3+
go 1.25
44

55
require (
66
github.com/go-chi/chi/v5 v5.2.2

handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ func (tm *TaskManager) runTask(taskCtx *taskContext) {
300300
taskCtx.result.ExitCode = waitStatus.ExitStatus()
301301
}
302302
}
303+
} else {
304+
// Success case
305+
taskCtx.result.ExitCode = 0
303306
}
304307
taskCtx.result.Status = status
305308

0 commit comments

Comments
 (0)