-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a324d34
commit 500b5e3
Showing
5 changed files
with
138 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
jobs: | ||
golang-test: | ||
strategy: | ||
matrix: | ||
go-version: [1.17.x] | ||
os: [ubuntu-latest] | ||
name: lint | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: latest | ||
- name: testing | ||
run: go test ./... -coverprofile=coverage.out | ||
- name: create report | ||
uses: k1LoW/octocov-action@v0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
coverage: | ||
paths: | ||
- coverage.out | ||
codeToTestRatio: | ||
code: | ||
- '**/*.go' | ||
- '!**/*_test.go' | ||
test: | ||
- '**/*_test.go' | ||
testExecutionTime: | ||
if: true | ||
comment: | ||
if: is_pull_request | ||
report: | ||
if: is_default_branch | ||
datastores: | ||
- artifact://${GITHUB_REPOSITORY} | ||
diff: | ||
datastores: | ||
- artifact://${GITHUB_REPOSITORY} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,92 @@ | ||
package trv | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
func TestConfig_getSourceList(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
c Config | ||
want []string | ||
}{ | ||
{ | ||
name: "The correct listing can be obtained from the source", | ||
c: Config{ | ||
Source: []Source{ | ||
{ | ||
Repo: "test1", | ||
Path: "testPath1", | ||
}, | ||
{ | ||
Repo: "test2", | ||
Path: "testPath2", | ||
}, | ||
}, | ||
}, | ||
want: []string{ | ||
"test1/testPath1", | ||
"test2/testPath2", | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := tt.c.getSourceList(); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("Config.getSourceList() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestConfig_addSource(t *testing.T) { | ||
type args struct { | ||
s Source | ||
} | ||
tests := []struct { | ||
name string | ||
c *Config | ||
args args | ||
want Config | ||
}{ | ||
{ | ||
name: "Correct source is added.", | ||
c: &Config{}, | ||
args: args{ | ||
s: Source{ | ||
Owner: "test", | ||
Repo: "test", | ||
Path: "test", | ||
IsEnterprise: false, | ||
Token: "test", | ||
BaseURL: "", | ||
UploadURL: "", | ||
}, | ||
}, | ||
want: Config{ | ||
Source: []Source{ | ||
{ | ||
Owner: "test", | ||
Repo: "test", | ||
Path: "test", | ||
IsEnterprise: false, | ||
Token: "test", | ||
BaseURL: "", | ||
UploadURL: "", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
tt.c.addSource(tt.args.s) | ||
if diff := cmp.Diff(tt.c.Source, tt.want.Source); diff != "" { | ||
t.Errorf("Source value is mismatch (-get +want):\n%s", diff) | ||
} | ||
}) | ||
} | ||
} |