forked from gobuffalo/pop
-
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.
…#149) * Soda v4.5.11 Broke Back Quotes in Fizz fixes gobuffalo#148 * Update file_migrator.go
- Loading branch information
Showing
4 changed files
with
102 additions
and
11 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
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,53 @@ | ||
package fix | ||
|
||
import ( | ||
"io/ioutil" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/gobuffalo/packr" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_Anko(t *testing.T) { | ||
r := require.New(t) | ||
box := packr.NewBox("./fixtures") | ||
err := box.Walk(func(path string, info packr.File) error { | ||
if strings.HasPrefix(path, "pass") { | ||
t.Run(path, testPass(path, info)) | ||
return nil | ||
} | ||
t.Run(path, testFail(path, info)) | ||
return nil | ||
}) | ||
r.NoError(err) | ||
} | ||
|
||
func testPass(path string, info packr.File) func(*testing.T) { | ||
return func(t *testing.T) { | ||
r := require.New(t) | ||
b, err := ioutil.ReadAll(info) | ||
r.NoError(err) | ||
|
||
body := string(b) | ||
fixed, err := Anko(body) | ||
r.NoError(err) | ||
if strings.Contains(path, "anko") { | ||
r.NotEqual(body, fixed) | ||
} else { | ||
r.Equal(body, fixed) | ||
} | ||
} | ||
} | ||
|
||
func testFail(path string, info packr.File) func(*testing.T) { | ||
return func(t *testing.T) { | ||
r := require.New(t) | ||
b, err := ioutil.ReadAll(info) | ||
r.NoError(err) | ||
|
||
body := string(b) | ||
_, err = Anko(body) | ||
r.Error(err) | ||
} | ||
} |
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 @@ | ||
create_table("users", func(t) { | ||
t.Column("email", "string", {}) | ||
t.Column("twitter_handle", "string", {"size": 50}) | ||
t.Column("age", "integer", {"default": 0}) | ||
t.Column("admin", "bool", {"default": false}) | ||
t.Column("company_id", "uuid", {"default_raw": "uuid_generate_v1()"}) | ||
t.Column("bio", "text", {"null": true}) | ||
t.Column("joined_at", "timestamp", {}) | ||
}) | ||
|
||
raw(` | ||
INSERT INTO users (email, twitter_handle, joined_at, created_at, updated_at) | ||
VALUES ('[email protected]', 'Soman1994', now(), now(), now()); | ||
`) |
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 @@ | ||
create_table("users") { | ||
t.Column("email", "string", {}) | ||
t.Column("twitter_handle", "string", {"size": 50}) | ||
t.Column("age", "integer", {"default": 0}) | ||
t.Column("admin", "bool", {"default": false}) | ||
t.Column("company_id", "uuid", {"default_raw": "uuid_generate_v1()"}) | ||
t.Column("bio", "text", {"null": true}) | ||
t.Column("joined_at", "timestamp", {}) | ||
} | ||
|
||
sql(" | ||
INSERT INTO users (email, twitter_handle, joined_at, created_at, updated_at) | ||
VALUES ('[email protected]', 'Soman1994', now(), now(), now()); | ||
") |