ci: add a workflow for tests #52
4 changed files with 83 additions and 0 deletions
6
.forgejo/actions/mage/Dockerfile
Normal file
6
.forgejo/actions/mage/Dockerfile
Normal file
|
@ -0,0 +1,6 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM golang:1.23.0
|
||||
|
||||
RUN go install github.com/magefile/mage@v1.15.0
|
||||
|
||||
ENTRYPOINT ["mage"]
|
16
.forgejo/actions/mage/action.yaml
Normal file
16
.forgejo/actions/mage/action.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
name: "Enbas Mage Action"
|
||||
description: "Runs a mage target in the Enbas project"
|
||||
|
||||
inputs:
|
||||
target:
|
||||
description: "The mage target to run"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
entrypoint: "mage"
|
||||
args:
|
||||
- -v
|
||||
- ${{ inputs.target }}
|
23
.forgejo/workflows/Tests.yaml
Normal file
23
.forgejo/workflows/Tests.yaml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
test:
|
||||
if: ${{ ! github.event.pull_request.draft }}
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- name: Test
|
||||
uses: ./.forgejo/actions/mage
|
||||
with:
|
||||
target: test
|
||||
env:
|
||||
ENBAS_TEST_VERBOSE: "1"
|
||||
ENBAS_TEST_COVER: "1"
|
38
internal/utilities/utilities_test.go
Normal file
38
internal/utilities/utilities_test.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package utilities_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/utilities"
|
||||
)
|
||||
|
||||
func TestGetFQDN(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
instance string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
instance: "https://gts.red-crow.private",
|
||||
want: "gts.red-crow.private",
|
||||
},
|
||||
{
|
||||
instance: "http://gotosocial.yellow-desert.social",
|
||||
want: "gotosocial.yellow-desert.social",
|
||||
},
|
||||
{
|
||||
instance: "fedi.blue-mammoth.party",
|
||||
want: "fedi.blue-mammoth.party",
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
got := utilities.GetFQDN(c.instance)
|
||||
if c.want != got {
|
||||
t.Errorf("Unexpected result: want %s, got %s", c.want, got)
|
||||
} else {
|
||||
t.Logf("Expected result: got %s", got)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue