Initial commit
This commit is contained in:
commit
01296bd2e6
8
.woodpecker/pr.yml
Normal file
8
.woodpecker/pr.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
pipeline:
|
||||||
|
test_short:
|
||||||
|
image: golang:latest
|
||||||
|
commands:
|
||||||
|
- go build main.go
|
||||||
|
- go test -v ./...
|
||||||
|
when:
|
||||||
|
event: [pull_request]
|
28
.woodpecker/push.yml
Normal file
28
.woodpecker/push.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
pipeline:
|
||||||
|
release-latest:
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: registry.t-juice.club/peckertest
|
||||||
|
registry: registry.t-juice.club
|
||||||
|
username: woodpecker
|
||||||
|
password:
|
||||||
|
from_secret: registry_password
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- "${CI_COMMIT_SHA:0:8}"
|
||||||
|
when:
|
||||||
|
branch: master
|
||||||
|
event: push
|
||||||
|
|
||||||
|
release-tagged:
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: registry.t-juice.club/peckertest
|
||||||
|
registry: registry.t-juice.club
|
||||||
|
username: woodpecker
|
||||||
|
password:
|
||||||
|
from_secret: registry_password
|
||||||
|
tags:
|
||||||
|
- "${CI_COMMIT_TAG}"
|
||||||
|
when:
|
||||||
|
event: [tag]
|
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM golang:latest AS builder
|
||||||
|
WORKDIR /src
|
||||||
|
COPY go.mod .
|
||||||
|
RUN go mod download
|
||||||
|
COPY . .
|
||||||
|
RUN go build -o peckertest main.go
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
COPY --from=builder /src/peckertest /bin/peckertest
|
||||||
|
CMD ["/bin/peckertest"]
|
5
internal/internal.go
Normal file
5
internal/internal.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
func Add(a, b int) int {
|
||||||
|
return a + b
|
||||||
|
}
|
30
internal/internal_test.go
Normal file
30
internal/internal_test.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package internal_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.t-juice.club/torjus/peckertest/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAdd(t *testing.T) {
|
||||||
|
var tc = []struct {
|
||||||
|
A int
|
||||||
|
B int
|
||||||
|
Expected int
|
||||||
|
}{
|
||||||
|
{A: 1, B: 0, Expected: 1},
|
||||||
|
{A: 1, B: 1, Expected: 2},
|
||||||
|
{A: 1, B: -1, Expected: 0},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tc {
|
||||||
|
name := fmt.Sprintf("%d+%d", test.A, test.B)
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
result := internal.Add(test.A, test.B)
|
||||||
|
if result != test.Expected {
|
||||||
|
t.Errorf("Got %d, expected %d", result, test.Expected)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user