Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(github): run go test at each push #301

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
name: CI
on:
push:
tags:
- '*'
jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21.x'
- name: Install dependencies
run: go get .
- name: Test with the Go CLI
run: go test ./...
release:
runs-on: ubuntu-latest
needs: test
if: startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
# Required to build changeleg
Expand Down
19 changes: 12 additions & 7 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
func TestNew(t *testing.T) {
os.Clearenv()
_, f, _, _ := runtime.Caller(0)
foundIface, err := chooseInterface(application.Flags{})
if err != nil {
panic(err)
}
testdir := filepath.Join(filepath.Dir(f), "testdata")
tempfile, err := ioutil.TempFile("", "qrcp*tmp.yml")
if err != nil {
Expand All @@ -31,7 +35,6 @@ func TestNew(t *testing.T) {
type args struct {
app application.App
}

tests := []struct {
name string
args args
Expand All @@ -46,7 +49,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
Port: 9090,
},
},
Expand All @@ -59,7 +62,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
},
},
{
Expand All @@ -71,7 +74,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
},
},
{
Expand All @@ -83,7 +86,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
Port: 18080,
KeepAlive: false,
Bind: "10.20.30.40",
Expand All @@ -105,7 +108,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
Port: 99999,
Bind: "10.20.30.40",
KeepAlive: false,
Expand All @@ -120,7 +123,9 @@ func TestNew(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := New(tt.args.app); !reflect.DeepEqual(got, tt.want) {
got := New(tt.args.app)
got.Interface = foundIface
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("New() = %v, want %v", got, tt.want)
}
})
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/full.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface: wlo1
interface: __PLACEHOLDER_INTERFACE__
port: 18080
bind: '10.20.30.40'
keepAlive: false
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/qrcp.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
interface: wlo1
interface: __PLACEHOLDER_INTERFACE__