Skip to content

Commit

Permalink
fix: fail is option used twice
Browse files Browse the repository at this point in the history
  • Loading branch information
evilmonkeyinc committed Feb 2, 2022
1 parent 6ae32a0 commit 54f3e2e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ jobs:
id: changes
run: |
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)"
echo "${{ steps.changes.outputs.changes}}"
echo ${{ steps.changes.outputs.changes}}
2 changes: 1 addition & 1 deletion .github/workflows/push_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Get changed files
id: changes
run: |
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)"
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)"
release:
runs-on: ubuntu-latest
needs: [release_check]
Expand Down
1 change: 1 addition & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

var (
errDataIsUnexpectedTypeOrNil error = fmt.Errorf("unexpected type or nil")
errOptionAlreadySet error = fmt.Errorf("option already set")
)

func getInvalidJSONData(reason error) error {
Expand Down
3 changes: 2 additions & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func QueryOptions(options *option.QueryOptions) Option {
return OptionFunction(func(selector *Selector) error {
if selector.Options == nil {
selector.Options = options
return nil
}
return nil
return errOptionAlreadySet
})
}
2 changes: 1 addition & 1 deletion options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func Test_QueryOptions(t *testing.T) {
assert.Nil(t, err)

err = option2.Apply(selector)
assert.Nil(t, err)
assert.EqualError(t, err, "option already set")

assert.Equal(t, input1, selector.Options)
assert.NotEqual(t, input2, selector.Options)
Expand Down

0 comments on commit 54f3e2e

Please sign in to comment.