Skip to content

Commit

Permalink
Merge pull request #22 from k1LoW/update-goccy-go-yaml
Browse files Browse the repository at this point in the history
Update goccy/go-yaml to v1.5.1
  • Loading branch information
k1LoW authored May 31, 2020
2 parents 743a523 + 08945a8 commit 23c8133
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 104 deletions.
26 changes: 23 additions & 3 deletions format/frgm/frgm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,43 @@ func TestEncode(t *testing.T) {
- uid: frgm-de1fbe2f7573
group: my-group
name: hello world
content: echo hello world
output: hello world
desc: |
show following
hello world
content: echo hello world
output: hello world
`,
},
{
snippets: snippet.Snippets{
snippet.New("frgm-de1fbe2f7573", "my-group", "count access.log", `cat /var/log/nginx/access.log | awk '{ if (($1 == "domain:example.com") && ($8 ~ /^status:[2345]/)) { arr[$8]++; x++ } } END { for (i in arr) { printf "%s\t%.2f%\t%s / %s\n", i, arr[i]/x*100, arr[i], x } }' | sort -nk1`, "", "", []string{}),
},
want: `snippets:
- uid: frgm-de1fbe2f7573
group: my-group
name: count access.log
content: "cat /var/log/nginx/access.log | awk '{ if (($1 == \"domain:example.com\") && ($8 ~ /^status:[2345]/)) { arr[$8]++; x++ } } END { for (i in arr) { printf \"%s\\t%.2f%\\t%s / %s\\n\", i, arr[i]/x*100, arr[i], x } }' | sort -nk1"
`,
},
}

frgm := New([]string{})
for _, tt := range tests {
out := new(bytes.Buffer)
frgm.Encode(out, tt.snippets)
if err := frgm.Encode(out, tt.snippets); err != nil {
t.Fatal(err)
}
got := out.String()
if got != tt.want {
t.Errorf("got %v\nwant %v", got, tt.want)
}
set, err := frgm.LoadSet(out, "default")
if err != nil {
t.Fatal(err)
}
if diff := cmp.Diff(set.Snippets, tt.snippets, nil); diff != "" {
t.Errorf("%s", diff)
}
}
}

Expand Down
7 changes: 1 addition & 6 deletions format/history/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,30 @@ func TestDecode(t *testing.T) {
Group: "default",
Name: "man history",
Content: "man history",
Labels: []string{},
},
&snippet.Snippet{
UID: "history-709a48a0dc97",
Group: "default",
Name: "git checkout -b format-history",
Content: "git checkout -b format-history",
Labels: []string{},
},
&snippet.Snippet{
UID: "history-fd42cee8fd75",
Group: "default",
Name: "emacs format/",
Content: "emacs format/",
Labels: []string{},
},
&snippet.Snippet{
UID: "history-00b0136f1cf7",
Group: "default",
Name: "go test ./format/history",
Content: "go test ./format/history",
Labels: []string{},
},
&snippet.Snippet{
UID: "history-a3a97692f42a",
Group: "default",
Name: "exec ls",
Content: "ls",
Labels: []string{},
},
},
},
Expand All @@ -77,7 +72,7 @@ func TestDecode(t *testing.T) {
t.Fatal(err)
}
if diff := cmp.Diff(got, tt.want, nil); diff != "" {
t.Errorf("got\n%v\nwant\n%v", got, tt.want)
t.Errorf("%v\n", diff)
}
}
}
25 changes: 6 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,15 @@ go 1.13
require (
github.com/BurntSushi/toml v0.3.1
github.com/Songmu/prompter v0.3.0
github.com/fatih/color v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gobuffalo/packr/v2 v2.8.0
github.com/goccy/go-yaml v1.4.3
github.com/google/go-cmp v0.2.0
github.com/karrick/godirwalk v1.15.5
github.com/goccy/go-yaml v1.5.1
github.com/google/go-cmp v0.3.0
github.com/karrick/godirwalk v1.15.6
github.com/labstack/gommon v0.3.0
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-tty v0.0.3
github.com/mitchellh/mapstructure v1.2.2 // indirect
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pkg/errors v0.8.0
github.com/pkg/errors v0.9.1
github.com/sabhiram/go-gitignore v0.0.0-20180611051255-d3107576ba94
github.com/sirupsen/logrus v1.5.0 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v0.0.7
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.6.2
golang.org/x/crypto v0.0.0-20200403201458-baeed622b8d8 // indirect
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d // indirect
gopkg.in/ini.v1 v1.55.0 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.0
)
Loading

0 comments on commit 23c8133

Please sign in to comment.