Skip to content
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
20 changes: 12 additions & 8 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ jobs:
golint -set_exit_status=1 ./...
release_check:
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.changes.outputs.changes}}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Get changed files
id: changes
fetch-depth: 0
- name: Check Diff
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
+**/*.go
!**/*_test.go
FILES: |
go.mod
- name: Output Diff
if: env.GIT_DIFF
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 ${{ env.GIT_DIFF }}
20 changes: 13 additions & 7 deletions .github/workflows/push_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,27 @@ jobs:
release_check:
runs-on: ubuntu-latest
needs: [test, lint]
outputs:
changes: ${{ steps.changes.outputs.changes}}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Get changed files
id: changes
fetch-depth: 0
- name: Check Diff
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
+**/*.go
!**/*_test.go
FILES: |
go.mod
- name: Output Diff
if: env.GIT_DIFF
run: |
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)"
echo ${{ env.GIT_DIFF }}
release:
runs-on: ubuntu-latest
needs: [release_check]
if: ${{needs.release_check.outputs.changes}}
if: env.GIT_DIFF
outputs:
version: ${{ steps.release.outputs.version }}
steps:
Expand Down
15 changes: 0 additions & 15 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
var _ Option = OptionFunction(func(selector *Selector) error { return nil })

func Test_OptionFunction(t *testing.T) {

t.Run("nil", func(t *testing.T) {
called := false
option := OptionFunction(func(selector *Selector) error {
Expand All @@ -23,7 +22,6 @@ func Test_OptionFunction(t *testing.T) {
assert.Nil(t, err)
assert.True(t, called)
})

t.Run("error", func(t *testing.T) {
called := false
option := OptionFunction(func(selector *Selector) error {
Expand All @@ -34,24 +32,19 @@ func Test_OptionFunction(t *testing.T) {
assert.EqualError(t, err, "fail")
assert.True(t, called)
})

}

func Test_ScriptEngine(t *testing.T) {

t.Run("first", func(t *testing.T) {

engine := &testScriptEngine{value: 1}
option := ScriptEngine(engine)
selector := &Selector{}

err := option.Apply(selector)
assert.Nil(t, err)
assert.Equal(t, engine, selector.engine)

})
t.Run("second", func(t *testing.T) {

engine1 := &testScriptEngine{value: 1}
engine2 := &testScriptEngine{value: 2}

Expand All @@ -68,26 +61,20 @@ func Test_ScriptEngine(t *testing.T) {

assert.Equal(t, engine1, selector.engine)
assert.NotEqual(t, engine2, selector.engine)

})

}

func Test_QueryOptions(t *testing.T) {

t.Run("first", func(t *testing.T) {

input := &option.QueryOptions{AllowMapReferenceByIndex: true, AllowStringReferenceByIndex: true}
option := QueryOptions(input)
selector := &Selector{}

err := option.Apply(selector)
assert.Nil(t, err)
assert.Equal(t, input, selector.Options)

})
t.Run("second", func(t *testing.T) {

input1 := &option.QueryOptions{AllowMapReferenceByIndex: true, AllowStringReferenceByIndex: true}
input2 := &option.QueryOptions{AllowMapReferenceByIndex: false, AllowStringReferenceByIndex: false}

Expand All @@ -104,7 +91,5 @@ func Test_QueryOptions(t *testing.T) {

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

})

}