Skip to content

Commit 31a5baf

Browse files
Merge pull request #19 from evilmonkeyinc/fix/option_error
fix: fail is option used twice
2 parents 6ae32a0 + 54f3e2e commit 31a5baf

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

.github/workflows/pull_request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ jobs:
6161
id: changes
6262
run: |
6363
echo "::set-output name=changes::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep 'go.mod\|.go$' | grep -v _test.go$ | xargs)"
64-
echo "${{ steps.changes.outputs.changes}}"
64+
echo ${{ steps.changes.outputs.changes}}
6565

.github/workflows/push_main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
- name: Get changed files
8383
id: changes
8484
run: |
85-
echo "::set-output name=changes::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep 'go.mod\|.go$' | grep -v _test.go$ | xargs)"
85+
echo "::set-output name=changes::$(git diff --name-only --diff-filter=ACMRT origin/main origin/${GITHUB_HEAD_REF} | grep 'go.mod\|.go$' | grep -v _test.go$ | xargs)"
8686
release:
8787
runs-on: ubuntu-latest
8888
needs: [release_check]

errors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
var (
1111
errDataIsUnexpectedTypeOrNil error = fmt.Errorf("unexpected type or nil")
12+
errOptionAlreadySet error = fmt.Errorf("option already set")
1213
)
1314

1415
func getInvalidJSONData(reason error) error {

options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func QueryOptions(options *option.QueryOptions) Option {
3434
return OptionFunction(func(selector *Selector) error {
3535
if selector.Options == nil {
3636
selector.Options = options
37+
return nil
3738
}
38-
return nil
39+
return errOptionAlreadySet
3940
})
4041
}

options_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func Test_QueryOptions(t *testing.T) {
100100
assert.Nil(t, err)
101101

102102
err = option2.Apply(selector)
103-
assert.Nil(t, err)
103+
assert.EqualError(t, err, "option already set")
104104

105105
assert.Equal(t, input1, selector.Options)
106106
assert.NotEqual(t, input2, selector.Options)

0 commit comments

Comments
 (0)