-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent new line adding in SED. Upgrade go to 1.20. Add unit tests
- Loading branch information
1 parent
8b25181
commit 6d46d4b
Showing
7 changed files
with
68 additions
and
9 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,14 @@ | ||
name: "Release a tag" | ||
on: push | ||
|
||
jobs: | ||
test-unit: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
- name: Test Unit | ||
run: go test -v ./... |
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,20 +1,23 @@ | ||
module protty | ||
|
||
go 1.18 | ||
go 1.20 | ||
|
||
require ( | ||
github.com/graze/go-throttled v0.3.1 | ||
github.com/itchyny/gojq v0.12.11 | ||
github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef | ||
github.com/sirupsen/logrus v1.9.0 | ||
github.com/spf13/cobra v1.6.1 | ||
github.com/thoas/go-funk v0.9.3 | ||
github.com/stretchr/testify v1.7.0 | ||
golang.org/x/time v0.3.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/inconshreveable/mousetrap v1.0.1 // indirect | ||
github.com/itchyny/timefmt-go v0.1.5 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
golang.org/x/sys v0.2.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
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
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,41 @@ | ||
package util | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestSED_Success(t *testing.T) { | ||
type args struct { | ||
msg string | ||
input string | ||
expr string | ||
} | ||
tests := []struct { | ||
args args | ||
want string | ||
}{ | ||
{ | ||
args{"New line can be replaced", "first line\nsecond line", `:a;N;$!ba;s/\n/,/g`}, | ||
"first line,second line", | ||
}, | ||
{ | ||
args{"New line doesn't add at the end", "Hello sed", `s/sed/world/`}, | ||
"Hello world", | ||
}, | ||
{ | ||
args{"New line doesn't remove from the end", "Hello sed\n", `s/sed/world/`}, | ||
"Hello world\n", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.args.msg, func(t *testing.T) { | ||
t.Parallel() | ||
actual, _, err := SED(tt.args.expr, []byte(tt.args.input)) | ||
assert.NoError(t, err) | ||
assert.Equal(t, tt.want, string(actual)) | ||
}) | ||
} | ||
} |