Skip to content
This repository was archived by the owner on Feb 24, 2024. It is now read-only.

Commit 7ac9719

Browse files
authored
Merge pull request #5 from kohbis/feature/add_test_workflow
Feature/add test workflow
2 parents a51aa90 + b268e7b commit 7ac9719

File tree

3 files changed

+68
-7
lines changed

3 files changed

+68
-7
lines changed

.github/workflows/feature.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: feature
2+
3+
on:
4+
push:
5+
branches:
6+
- 'feature/**'
7+
8+
jobs:
9+
setup:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v1
14+
- name: Setup Go
15+
uses: actions/setup-go@v1
16+
with:
17+
go-version: 1.15
18+
- name: Test
19+
run: go test -v ./...

.github/workflows/release.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ on:
66
- "v[0-9]+.[0-9]+.[0-9]+"
77

88
jobs:
9-
goreleaser:
9+
setup:
1010
runs-on: ubuntu-latest
1111
steps:
12-
-
13-
name: Checkout
12+
- name: Checkout
1413
uses: actions/checkout@v1
15-
-
16-
name: Setup Go
14+
- name: Setup Go
1715
uses: actions/setup-go@v1
1816
with:
1917
go-version: 1.15
20-
-
21-
name: Run GoReleaser
18+
- name: Test
19+
run: go test -v ./...
20+
21+
goreleaser:
22+
needs: setup
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Run GoReleaser
2226
uses: goreleaser/goreleaser-action@v1
2327
with:
2428
version: latest

cmd/root_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package cmd
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func Test_commandExists(t *testing.T) {
8+
type args struct {
9+
cmd string
10+
}
11+
tests := []struct {
12+
name string
13+
args args
14+
want bool
15+
}{
16+
{
17+
name: "return true if command exist",
18+
args: args{
19+
"ls",
20+
},
21+
want: true,
22+
},
23+
{
24+
name: "return false if command not exist",
25+
args: args{
26+
"may_not_exist",
27+
},
28+
want: false,
29+
},
30+
}
31+
for _, tt := range tests {
32+
t.Run(tt.name, func(t *testing.T) {
33+
if got := commandExists(tt.args.cmd); got != tt.want {
34+
t.Errorf("commandExists() = %v, want %v", got, tt.want)
35+
}
36+
})
37+
}
38+
}

0 commit comments

Comments
 (0)