Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete the go formatter code as it is not longer used #3998

Merged
merged 1 commit into from
Sep 9, 2021
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
59 changes: 31 additions & 28 deletions ast/edit/option_editor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/influxdata/flux/ast"
"github.com/influxdata/flux/ast/astutil"
"github.com/influxdata/flux/ast/edit"
"github.com/influxdata/flux/parser"
"github.com/influxdata/flux/values"
Expand All @@ -21,7 +22,7 @@ func TestEditor(t *testing.T) {
{
name: "no_option",
in: `from(bucket: "test")
|> range(start: 2018-05-23T13:09:22.885021542Z)`,
|> range(start: 2018-05-23T13:09:22.885021542Z)`,
unchanged: true,
edit: func(node ast.Node) (bool, error) {
return edit.Option(node, "from", nil)
Expand Down Expand Up @@ -58,20 +59,20 @@ option bar = 42`,
{
name: "updates_object",
in: `option foo = 1
option task = {
name: "bar",
every: 1m,
delay: 1m,
cron: "20 * * *",
retry: 5,
option task = {
name: "bar",
every: 1m,
delay: 1m,
cron: "20 * * *",
retry: 5,
}`,
edited: `option foo = 1
option task = {
name: "bar",
every: 2h3m10s,
delay: 42m,
cron: "buz",
retry: 10,
name: "bar",
every: 2h3m10s,
delay: 42m,
cron: "buz",
retry: 10,
}`,
edit: func(node ast.Node) (bool, error) {
every, err := parser.ParseDuration("2h3m10s")
Expand All @@ -94,19 +95,19 @@ option task = {
name: "error_key_not_found",
in: `option foo = 1
option task = {
name: "bar",
every: 1m,
delay: 1m,
cron: "20 * * *",
retry: 5,
name: "bar",
every: 1m,
delay: 1m,
cron: "20 * * *",
retry: 5,
}`, edited: `option foo = 1
option task = {
name: "bar",
every: 2h,
delay: 1m,
cron: "20 * * *",
retry: 5,
foo: "foo",
name: "bar",
every: 2h,
delay: 1m,
cron: "20 * * *",
retry: 5,
foo: "foo",
}`,
errorWanted: false,
edit: func(node ast.Node) (bool, error) {
Expand Down Expand Up @@ -211,10 +212,9 @@ option task = {
},
},
{
name: "sets_option_to_function",
in: `option now = "edit me"`,
edited: `option now = () =>
(2018-12-03T20:52:48.464942Z)`,
name: "sets_option_to_function",
in: `option now = "edit me"`,
edited: `option now = () => 2018-12-03T20:52:48.464942Z`,
edit: func(node ast.Node) (bool, error) {
t, err := values.ParseTime("2018-12-03T20:52:48.464942000Z")
if err != nil {
Expand Down Expand Up @@ -256,7 +256,10 @@ option task = {
t.Fatal("unexpected option edit")
}

out := ast.Format(p.Files[0])
out, err := astutil.Format(p.Files[0])
if err != nil {
t.Fatalf("got unexpected error from formatter: %s", err)
}

if out != tc.edited {
t.Errorf("\nexpected:\n%s\nedited:\n%s\n", tc.edited, out)
Expand Down
23 changes: 14 additions & 9 deletions ast/edit/testcase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/influxdata/flux/ast"
"github.com/influxdata/flux/ast/asttest"
"github.com/influxdata/flux/ast/astutil"
"github.com/influxdata/flux/ast/edit"
"github.com/influxdata/flux/dependencies/filesystem"
"github.com/influxdata/flux/parser"
Expand Down Expand Up @@ -126,7 +127,11 @@ testcase b extends "flux/a/a_test" {

files := make([]string, len(pkgs[0].Files))
for i, file := range pkgs[0].Files {
files[i] = ast.Format(file)
fileStr, err := astutil.Format(file)
if err != nil {
t.Fatalf("unexpected error from formatter: %s", err)
}
files[i] = fileStr
}

want := []string{
Expand All @@ -135,16 +140,16 @@ testcase b extends "flux/a/a_test" {

import "testing/assert"

a_test = () => {
want = 4
a = () => {
assert.equal(want: want, got: 2 + 2)
a_test = (() => {
want = 4
a = () => {
assert.equal(want: want, got: 2 + 2)

return {}
}
return {}
}

return {want, a}
}()`,
return {want, a}
})()`,
`package main


Expand Down
Loading